From 2aff5fdd706e31c67c7c793d8eb898ab7070fd78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tatiana=20Castro-V=C3=A9lez?= Date: Fri, 30 Jun 2023 15:45:49 -0400 Subject: [PATCH] Fix extra function caused by additional summary entries for tensor generators (#80) Fixes the XML summaries so that the FQN imports (ex. `from tensorflow.python.ops.variables import Variable`) and traditional imports (ex. `import tensorflow as tf`, `import tensorflow`) when using the same API count as the same class. --- .../python/ml/test/TestTensorflowModel.java | 30 +- .../data/tensorflow.xml | 268 +++--------------- com.ibm.wala.cast.python.test/data/tf2d5.py | 7 + com.ibm.wala.cast.python.test/data/tf2e8.py | 7 + 4 files changed, 73 insertions(+), 239 deletions(-) create mode 100644 com.ibm.wala.cast.python.test/data/tf2d5.py create mode 100644 com.ibm.wala.cast.python.test/data/tf2e8.py diff --git a/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflowModel.java b/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflowModel.java index d35c26100..8d17314ce 100644 --- a/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflowModel.java +++ b/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflowModel.java @@ -65,40 +65,42 @@ public void testTf2() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { testTf2("tf2.py", "add", 2, 3, 2, 3); testTf2("tf2b.py", "add", 2, 3, 2, 3); - testTf2("tf2c.py", "add", 2, 4, 2, 3); + testTf2("tf2c.py", "add", 2, 3, 2, 3); testTf2("tf2d.py", "add", 2, 3, 2, 3); testTf2("tf2d2.py", "add", 2, 3, 2, 3); testTf2("tf2d3.py", "add", 2, 3, 2, 3); - testTf2("tf2d4.py", "add", 2, 4, 2, 3); + testTf2("tf2d4.py", "add", 2, 3, 2, 3); + testTf2("tf2d5.py", "add", 2, 3, 2, 3); testTf2("tf2e.py", "add", 2, 3, 2, 3); - testTf2("tf2e2.py", "add", 2, 4, 2, 3); + testTf2("tf2e2.py", "add", 2, 3, 2, 3); testTf2("tf2e3.py", "add", 2, 3, 2, 3); - testTf2("tf2e4.py", "add", 2, 4, 2, 3); + testTf2("tf2e4.py", "add", 2, 3, 2, 3); testTf2("tf2e5.py", "add", 2, 3, 2, 3); testTf2("tf2e6.py", "add", 2, 3, 2, 3); testTf2("tf2e7.py", "add", 2, 3, 2, 3); + testTf2("tf2e8.py", "add", 2, 3, 2, 3); testTf2("tf2f.py", "add", 2, 3, 2, 3); - testTf2("tf2f2.py", "add", 2, 4, 2, 3); - testTf2("tf2f3.py", "add", 2, 4, 2, 3); + testTf2("tf2f2.py", "add", 2, 3, 2, 3); + testTf2("tf2f3.py", "add", 2, 3, 2, 3); testTf2("tf2g.py", "add", 2, 3, 2, 3); - testTf2("tf2g2.py", "add", 2, 4, 2, 3); + testTf2("tf2g2.py", "add", 2, 3, 2, 3); testTf2("tf2h.py", "add", 2, 3, 2, 3); - testTf2("tf2h2.py", "add", 2, 4, 2, 3); + testTf2("tf2h2.py", "add", 2, 3, 2, 3); testTf2("tf2i.py", "add", 2, 3, 2, 3); - testTf2("tf2i2.py", "add", 2, 4, 2, 3); + testTf2("tf2i2.py", "add", 2, 3, 2, 3); testTf2("tf2j.py", "add", 2, 3, 2, 3); - testTf2("tf2j2.py", "add", 2, 4, 2, 3); + testTf2("tf2j2.py", "add", 2, 3, 2, 3); testTf2("tf2k.py", "add", 2, 3, 2, 3); - testTf2("tf2k2.py", "add", 2, 4, 2, 3); + testTf2("tf2k2.py", "add", 2, 3, 2, 3); testTf2("tf2l.py", "add", 2, 3, 2, 3); - testTf2("tf2l2.py", "add", 2, 4, 2, 3); + testTf2("tf2l2.py", "add", 2, 3, 2, 3); testTf2("tf2m.py", "add", 2, 3, 2, 3); - testTf2("tf2m2.py", "add", 2, 4, 2, 3); + testTf2("tf2m2.py", "add", 2, 3, 2, 3); testTf2("tf2n.py", "func2", 1, 4, 2); testTf2("tf2n2.py", "func2", 1, 4, 2); testTf2("tf2n3.py", "func2", 1, 4, 2); testTf2("tf2o.py", "add", 2, 3, 2, 3); - testTf2("tf2o2.py", "add", 2, 4, 2, 3); + testTf2("tf2o2.py", "add", 2, 3, 2, 3); testTf2("tf2p.py", "value_index", 2, 4, 2, 3); testTf2("tf2p2.py", "value_index", 2, 4, 2, 3); testTf2("tf2q.py", "add", 2, 3, 2, 3); diff --git a/com.ibm.wala.cast.python.ml/data/tensorflow.xml b/com.ibm.wala.cast.python.ml/data/tensorflow.xml index 7a2cc40e7..383d7c18e 100644 --- a/com.ibm.wala.cast.python.ml/data/tensorflow.xml +++ b/com.ibm.wala.cast.python.ml/data/tensorflow.xml @@ -57,45 +57,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -125,12 +86,13 @@ - - - + + + + @@ -146,53 +108,63 @@ - - - - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + @@ -521,160 +493,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/com.ibm.wala.cast.python.test/data/tf2d5.py b/com.ibm.wala.cast.python.test/data/tf2d5.py new file mode 100644 index 000000000..f04b6326e --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/tf2d5.py @@ -0,0 +1,7 @@ +from tensorflow.python.ops.random_ops import random_uniform + +def add(a, b): + return a + b + + +c = add(random_uniform([1, 2]), random_uniform([2, 2])) diff --git a/com.ibm.wala.cast.python.test/data/tf2e8.py b/com.ibm.wala.cast.python.test/data/tf2e8.py new file mode 100644 index 000000000..8d4b98425 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/tf2e8.py @@ -0,0 +1,7 @@ +from tensorflow.python.ops.variables import Variable + +def add(a, b): + return a + b + + +c = add(Variable([1., 2.]), Variable([2., 2.]))