Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extra function caused by additional summary entries for tensor generators #80

Merged
merged 1 commit into from
Jun 30, 2023

Conversation

tatianacv
Copy link
Contributor

@tatianacv tatianacv commented Jun 30, 2023

This PR 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. Therefore, there was a change in the expectedNumberOfTensorVariables because in

import tensorflow as tf
from tensorflow.python.ops.variables import Variable
def add(a, b):
return a + b
c = add(tf.Variable([1., 2.]), Variable([2., 2.]))
we don't count the two APIs as different, but one which is why in this PR we see a change from 4 to 3 in test such as the one above.

I also added a test that only included the FQN import to ensure we were processing that API. I added one test for the only level 2 API and one test for one of the level 1 APIs.

For example, tf2b.cpy and tf2c.py are essentially the same except having different ways of importing the same thing:

import tensorflow as tf
from tensorflow.python.ops.array_ops import ones
def add(a, b):
return a + b
c = add(tf.ones([1, 2]), ones([2, 2])) # [[2., 2.], [2., 2.]]

import tensorflow
def add(a, b):
return a + b
c = add(tensorflow.ones([1, 2]), tensorflow.ones([2, 2])) # [[2., 2.], [2., 2.]]

Yet, there are differences in the number of tensor variables identified (3 and 4, respectively).:

testTf2("tf2b.py", "add", 2, 3, 2, 3);
testTf2("tf2c.py", "add", 2, 4, 2, 3);

Now, we have (in this PR) 3 and 3 tensor variables, respectively (they are now the same despite the different ways of importing the same thing):
https://github.com/wala/ML/pull/80/files#diff-5b16d15bb6e50c03555d3801c21e05c34697088581cfc1c721a3b999355b5ffdL67-R68

Now, the XML summaries are structured more hierarchically.

@khatchad khatchad merged commit 2aff5fd into wala:master Jun 30, 2023
@khatchad khatchad deleted the contrib_additional_summary_entries branch June 30, 2023 19:45
khatchad added a commit that referenced this pull request Jan 30, 2024
* Use print() instead of print.

Black is complaining.

* Remove Python from spotless.

It's not working.

* Format Python code with black.

* Add black to CI.

* Modify black config.

* Format Python files.

* Use Black version 24.1.1.

* Apply spotless.

* Use pip to install Black on Travis CI.

* Upgrade Travis CI top Jammy.

* Use pip to install Black on GH Actions.

* Split Black and Python in GH Actions.

Was getting an error.

* Fix test.

Due to formatting.

* Try `requirements.txt`.

* Install Python dependencies on GH Actions.

* Explicitly install requirements on Travis CI.

* Change Black config.

* Remove direct Black calls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants