Skip to content

Commit

Permalink
Fix extra function caused by additional summary entries for tensor ge…
Browse files Browse the repository at this point in the history
…nerators (#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.
  • Loading branch information
tatianacv authored Jun 30, 2023
1 parent 8f0fba7 commit 2aff5fd
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 239 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
268 changes: 43 additions & 225 deletions com.ibm.wala.cast.python.ml/data/tensorflow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,45 +57,6 @@
<new def="reshape" class="Ltensorflow/functions/reshape" />
<putfield class="LRoot" field="reshape" fieldType="LRoot" ref="x" value="reshape" />

<new def="ones" class="Ltensorflow/functions/ones" />
<putfield class="LRoot" field="ones" fieldType="LRoot" ref="x" value="ones" />

<new def="Variable" class="Ltensorflow/functions/Variable" />
<putfield class="LRoot" field="Variable" fieldType="LRoot" ref="x" value="Variable" />

<new def="constant" class="Ltensorflow/functions/constant" />
<putfield class="LRoot" field="constant" fieldType="LRoot" ref="x" value="constant" />

<new def="zeros" class="Ltensorflow/functions/zeros" />
<putfield class="LRoot" field="zeros" fieldType="LRoot" ref="x" value="zeros" />

<new def="SparseTensor" class="Ltensorflow/functions/SparseTensor" />
<putfield class="LRoot" field="SparseTensor" fieldType="LRoot" ref="x" value="SparseTensor" />

<new def="fill" class="Ltensorflow/functions/fill" />
<putfield class="LRoot" field="fill" fieldType="LRoot" ref="x" value="fill" />

<new def="zeros_like" class="Ltensorflow/functions/zeros_like" />
<putfield class="LRoot" field="zeros_like" fieldType="LRoot" ref="x" value="zeros_like" />

<new def="one_hot" class="Ltensorflow/functions/one_hot" />
<putfield class="LRoot" field="one_hot" fieldType="LRoot" ref="x" value="one_hot" />

<new def="convert_to_tensor" class="Ltensorflow/functions/convert_to_tensor" />
<putfield class="LRoot" field="convert_to_tensor" fieldType="LRoot" ref="x" value="convert_to_tensor" />

<new def="range" class="Ltensorflow/functions/range" />
<putfield class="LRoot" field="range" fieldType="LRoot" ref="x" value="range" />

<new def="Tensor" class="Ltensorflow/functions/Tensor" />
<putfield class="LRoot" field="Tensor" fieldType="LRoot" ref="x" value="Tensor" />

<new def="eye" class="Ltensorflow/functions/eye" />
<putfield class="LRoot" field="eye" fieldType="LRoot" ref="x" value="eye" />

<new def="uniform" class="Ltensorflow/functions/uniform" />
<putfield class="LRoot" field="uniform" fieldType="LRoot" ref="random" value="uniform" />

<new def="conv2d" class="Ltensorflow/functions/conv2d" />
<putfield class="LRoot" field="conv2d" fieldType="LRoot" ref="x" value="conv2d" />
<putfield class="LRoot" field="conv2d" fieldType="LRoot" ref="nn" value="conv2d" />
Expand Down Expand Up @@ -125,12 +86,13 @@
<new def="python" class="Lobject" />
<putfield class="LRoot" field="python" fieldType="LRoot" ref="x" value="python" />

<new def="ops" class="Lobject" />
<putfield class="LRoot" field="ops" fieldType="LRoot" ref="python" value="ops" />

<new def="framework" class="Lobject" />
<putfield class="LRoot" field="framework" fieldType="LRoot" ref="python" value="framework" />

<new def="ops" class="Lobject" />
<putfield class="LRoot" field="ops" fieldType="LRoot" ref="python" value="ops" />
<putfield class="LRoot" field="ops" fieldType="LRoot" ref="framework" value="ops" />

<new def="array_ops" class="Lobject" />
<putfield class="LRoot" field="array_ops" fieldType="LRoot" ref="ops" value="array_ops" />

Expand All @@ -146,53 +108,63 @@
<new def="variables" class="Lobject" />
<putfield class="LRoot" field="variables" fieldType="LRoot" ref="ops" value="variables" />

<new def="ops2" class="Lobject" />
<putfield class="LRoot" field="ops" fieldType="LRoot" ref="framework" value="ops2" />

<new def="sparse_tensor" class="Lobject" />
<putfield class="LRoot" field="sparse_tensor" fieldType="LRoot" ref="framework" value="sparse_tensor" />

<new def="constant_op" class="Lobject" />
<putfield class="LRoot" field="constant_op" fieldType="LRoot" ref="framework" value="constant_op" />

<new def="fqn_Variable" class="Ltensorflow/python/ops/variables/Variable" />
<putfield class="LRoot" field="Variable" fieldType="LRoot" ref="variables" value="fqn_Variable" />
<new def="Variable" class="Ltensorflow/functions/Variable" />
<putfield class="LRoot" field="Variable" fieldType="LRoot" ref="x" value="Variable" />
<putfield class="LRoot" field="Variable" fieldType="LRoot" ref="variables" value="Variable" />

<new def="fqn_ones" class="Ltensorflow/python/ops/array_ops/ones" />
<putfield class="LRoot" field="ones" fieldType="LRoot" ref="array_ops" value="fqn_ones" />
<new def="ones" class="Ltensorflow/functions/ones" />
<putfield class="LRoot" field="ones" fieldType="LRoot" ref="x" value="ones" />
<putfield class="LRoot" field="ones" fieldType="LRoot" ref="array_ops" value="ones" />

<new def="fqn_zeros" class="Ltensorflow/python/ops/array_ops/zeros" />
<putfield class="LRoot" field="zeros" fieldType="LRoot" ref="array_ops" value="fqn_zeros" />
<new def="zeros" class="Ltensorflow/functions/zeros" />
<putfield class="LRoot" field="zeros" fieldType="LRoot" ref="x" value="zeros" />
<putfield class="LRoot" field="zeros" fieldType="LRoot" ref="array_ops" value="zeros" />

<new def="fqn_fill" class="Ltensorflow/python/ops/array_ops/fill" />
<putfield class="LRoot" field="fill" fieldType="LRoot" ref="array_ops" value="fqn_fill" />
<new def="fill" class="Ltensorflow/functions/fill" />
<putfield class="LRoot" field="fill" fieldType="LRoot" ref="x" value="fill" />
<putfield class="LRoot" field="fill" fieldType="LRoot" ref="array_ops" value="fill" />

<new def="fqn_zeros_like" class="Ltensorflow/python/ops/array_ops/zeros_like" />
<putfield class="LRoot" field="zeros_like" fieldType="LRoot" ref="array_ops" value="fqn_zeros_like" />
<new def="zeros_like" class="Ltensorflow/functions/zeros_like" />
<putfield class="LRoot" field="zeros_like" fieldType="LRoot" ref="x" value="zeros_like" />
<putfield class="LRoot" field="zeros_like" fieldType="LRoot" ref="array_ops" value="zeros_like" />

<new def="fqn_one_hot" class="Ltensorflow/python/ops/array_ops/one_hot" />
<putfield class="LRoot" field="one_hot" fieldType="LRoot" ref="array_ops" value="fqn_one_hot" />
<new def="one_hot" class="Ltensorflow/functions/one_hot" />
<putfield class="LRoot" field="one_hot" fieldType="LRoot" ref="x" value="one_hot" />
<putfield class="LRoot" field="one_hot" fieldType="LRoot" ref="array_ops" value="one_hot" />

<new def="fqn_random_uniform" class="Ltensorflow/python/ops/random_ops/random_uniform" />
<putfield class="LRoot" field="random_uniform" fieldType="LRoot" ref="random_ops" value="fqn_ones" />
<new def="uniform" class="Ltensorflow/functions/uniform" />
<putfield class="LRoot" field="uniform" fieldType="LRoot" ref="random" value="uniform" />
<putfield class="LRoot" field="random_uniform" fieldType="LRoot" ref="random_ops" value="uniform" />

<new def="fqn_range" class="Ltensorflow/python/ops/math_ops/range" />
<putfield class="LRoot" field="range" fieldType="LRoot" ref="math_ops" value="fqn_range" />
<new def="range" class="Ltensorflow/functions/range" />
<putfield class="LRoot" field="range" fieldType="LRoot" ref="x" value="range" />
<putfield class="LRoot" field="range" fieldType="LRoot" ref="math_ops" value="range" />

<new def="fqn_eye" class="Ltensorflow/python/ops/linalg_ops/eye" />
<putfield class="LRoot" field="eye" fieldType="LRoot" ref="linalg_ops" value="fqn_eye" />
<new def="eye" class="Ltensorflow/functions/eye" />
<putfield class="LRoot" field="eye" fieldType="LRoot" ref="x" value="eye" />
<putfield class="LRoot" field="eye" fieldType="LRoot" ref="linalg_ops" value="eye" />

<new def="fqn_constant" class="Ltensorflow/python/framework/constant_op/constant" />
<putfield class="LRoot" field="constant" fieldType="LRoot" ref="constant_op" value="fqn_constant" />
<new def="constant" class="Ltensorflow/functions/constant" />
<putfield class="LRoot" field="constant" fieldType="LRoot" ref="x" value="constant" />
<putfield class="LRoot" field="constant" fieldType="LRoot" ref="constant_op" value="constant" />

<new def="fqn_SparseTensor" class="Ltensorflow/python/framework/sparse_tensor/SparseTensor" />
<putfield class="LRoot" field="SparseTensor" fieldType="LRoot" ref="sparse_tensor" value="fqn_SparseTensor" />
<new def="SparseTensor" class="Ltensorflow/functions/SparseTensor" />
<putfield class="LRoot" field="SparseTensor" fieldType="LRoot" ref="x" value="SparseTensor" />
<putfield class="LRoot" field="SparseTensor" fieldType="LRoot" ref="sparse_tensor" value="SparseTensor" />

<new def="fqn_convert_to_tensor" class="Ltensorflow/python/framework/ops/convert_to_tensor" />
<putfield class="LRoot" field="convert_to_tensor" fieldType="LRoot" ref="ops2" value="fqn_convert_to_tensor" />
<new def="convert_to_tensor" class="Ltensorflow/functions/convert_to_tensor" />
<putfield class="LRoot" field="convert_to_tensor" fieldType="LRoot" ref="x" value="convert_to_tensor" />
<putfield class="LRoot" field="convert_to_tensor" fieldType="LRoot" ref="ops" value="convert_to_tensor" />

<new def="fqn_Tensor" class="Ltensorflow/python/framework/ops/Tensor" />
<putfield class="LRoot" field="Tensor" fieldType="LRoot" ref="ops2" value="fqn_Tensor" />
<new def="Tensor" class="Ltensorflow/functions/Tensor" />
<putfield class="LRoot" field="Tensor" fieldType="LRoot" ref="x" value="Tensor" />
<putfield class="LRoot" field="Tensor" fieldType="LRoot" ref="ops" value="Tensor" />

<return value="x" />
</method>
Expand Down Expand Up @@ -521,160 +493,6 @@
</class>
</package>

<package name="tensorflow/python/ops/array_ops">
<class name="ones" allocatable="true">
<method name="read_data" descriptor="()LRoot;">
<new def="x" class="Ltensorflow/python/ops/array_ops/ones" />
<return value="x" />
</method>
<method name="do" descriptor="()LRoot;" numArgs="3" paramNames="shape dtype name">
<call class="LRoot" name="read_data" descriptor="()LRoot;" type="virtual" arg0="arg0" def="x" />
<return value="x" />
</method>
</class>
<class name="zeros" allocatable="true">
<method name="read_data" descriptor="()LRoot;">
<new def="x" class="Ltensorflow/python/ops/array_ops/zeros" />
<return value="x" />
</method>
<method name="do" descriptor="()LRoot;" numArgs="3" paramNames="shape dtype name">
<call class="LRoot" name="read_data" descriptor="()LRoot;" type="virtual" arg0="arg0" def="x" />
<return value="x" />
</method>
</class>
<class name="fill" allocatable="true">
<method name="read_data" descriptor="()LRoot;">
<new def="x" class="Ltensorflow/python/ops/array_ops/fill" />
<return value="x" />
</method>
<method name="do" descriptor="()LRoot;" numArgs="3" paramNames="dims value name">
<call class="LRoot" name="read_data" descriptor="()LRoot;" type="virtual" arg0="arg0" def="x" />
<return value="x" />
</method>
</class>
<class name="zeros_like" allocatable="true">
<method name="read_data" descriptor="()LRoot;">
<new def="x" class="Ltensorflow/python/ops/array_ops/zeros_like" />
<return value="x" />
</method>
<method name="do" descriptor="()LRoot;" numArgs="3" paramNames="input dtype name">
<call class="LRoot" name="read_data" descriptor="()LRoot;" type="virtual" arg0="arg0" def="x" />
<return value="x" />
</method>
</class>
<class name="one_hot" allocatable="true">
<method name="read_data" descriptor="()LRoot;">
<new def="x" class="Ltensorflow/python/ops/array_ops/one_hot" />
<return value="x" />
</method>
<method name="do" descriptor="()LRoot;" numArgs="7" paramNames="indices depth on_value off_value axis dtype name">
<call class="LRoot" name="read_data" descriptor="()LRoot;" type="virtual" arg0="arg0" def="x" />
<return value="x" />
</method>
</class>
</package>

<package name="tensorflow/python/ops/random_ops">
<class name="random_uniform" allocatable="true">
<method name="read_data" descriptor="()LRoot;">
<new def="x" class="Ltensorflow/python/ops/random_ops/random_uniform" />
<return value="x" />
</method>
<method name="do" descriptor="()LRoot;" numArgs="6" paramNames="shape minval maxval dtype seed name">
<call class="LRoot" name="read_data" descriptor="()LRoot;" type="virtual" arg0="arg0" def="x" />
<return value="x" />
</method>
</class>
</package>

<package name="tensorflow/python/ops/math_ops">
<class name="range" allocatable="true">
<method name="read_data" descriptor="()LRoot;">
<new def="x" class="Ltensorflow/python/ops/math_ops/range" />
<return value="x" />
</method>
<method name="do" descriptor="()LRoot;" numArgs="4" paramNames="limit delta dtype name">
<call class="LRoot" name="read_data" descriptor="()LRoot;" type="virtual" arg0="arg0" def="x" />
<return value="x" />
</method>
</class>
</package>

<package name="tensorflow/python/ops/linalg_ops">
<class name="eye" allocatable="true">
<method name="read_data" descriptor="()LRoot;">
<new def="x" class="Ltensorflow/python/ops/linalg_ops/eye" />
<return value="x" />
</method>
<method name="do" descriptor="()LRoot;" numArgs="5" paramNames="num_rows num_columns batch_shape dtype name">
<call class="LRoot" name="read_data" descriptor="()LRoot;" type="virtual" arg0="arg0" def="x" />
<return value="x" />
</method>
</class>
</package>

<package name="tensorflow/python/ops/variables">
<class name="Variable" allocatable="true">
<method name="read_data" descriptor="()LRoot;">
<new def="x" class="Ltensorflow/python/ops/variables/Variable" />
<return value="x" />
</method>
<method name="do" descriptor="()LRoot;" numArgs="12" paramNames="initial_value trainable validate_shape caching_device name variable_def dtype import_scope constraint synchronization aggregation shape">
<call class="LRoot" name="read_data" descriptor="()LRoot;" type="virtual" arg0="arg0" def="x" />
<return value="x" />
</method>
</class>
</package>

<package name="tensorflow/python/framework/constant_op">
<class name="constant" allocatable="true">
<method name="read_data" descriptor="()LRoot;">
<new def="x" class="Ltensorflow/python/framework/constant_op/constant" />
<return value="x" />
</method>
<method name="do" descriptor="()LRoot;" numArgs="4" paramNames="value dtype shape name">
<call class="LRoot" name="read_data" descriptor="()LRoot;" type="virtual" arg0="arg0" def="x" />
<return value="x" />
</method>
</class>
</package>

<package name="tensorflow/python/framework/sparse_tensor">
<class name="SparseTensor" allocatable="true">
<method name="read_data" descriptor="()LRoot;">
<new def="x" class="Ltensorflow/python/framework/sparse_tensor/SparseTensor" />
<return value="x" />
</method>
<method name="do" descriptor="()LRoot;" numArgs="3" paramNames="indices values dense_shape">
<call class="LRoot" name="read_data" descriptor="()LRoot;" type="virtual" arg0="arg0" def="x" />
<return value="x" />
</method>
</class>
</package>

<package name="tensorflow/python/framework/ops">
<class name="convert_to_tensor" allocatable="true">
<method name="read_data" descriptor="()LRoot;">
<new def="x" class="Ltensorflow/python/framework/ops/convert_to_tensor" />
<return value="x" />
</method>
<method name="do" descriptor="()LRoot;" numArgs="4" paramNames="value dtype dtype_hint name">
<call class="LRoot" name="read_data" descriptor="()LRoot;" type="virtual" arg0="arg0" def="x" />
<return value="x" />
</method>
</class>
<class name="Tensor" allocatable="true">
<method name="read_data" descriptor="()LRoot;">
<new def="x" class="Ltensorflow/python/framework/ops/Tensor" />
<return value="x" />
</method>
<method name="do" descriptor="()LRoot;" numArgs="3" paramNames="op value_index dtype">
<call class="LRoot" name="read_data" descriptor="()LRoot;" type="virtual" arg0="arg0" def="x" />
<return value="x" />
</method>
</class>
</package>

<package name="tensorflow/examples/tutorials">
<class name="mnist" allocatable="true">
<method name="import" static="true" descriptor="()Ltensorflow/examples/tutorials/mnist;">
Expand Down
Loading

0 comments on commit 2aff5fd

Please sign in to comment.