-
Notifications
You must be signed in to change notification settings - Fork 17
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
__call__
not supported
#24
Comments
Suppose we have this input code stored in import tensorflow as tf
# Create an override model to classify pictures
class SequentialModel(tf.keras.Model):
def __init__(self, **kwargs):
super(SequentialModel, self).__init__(**kwargs)
self.flatten = tf.keras.layers.Flatten(input_shape=(28, 28))
# Add a lot of small layers
num_layers = 100
self.my_layers = [tf.keras.layers.Dense(64, activation="relu")
for n in range(num_layers)]
self.dropout = tf.keras.layers.Dropout(0.2)
self.dense_2 = tf.keras.layers.Dense(10)
def __call__(self, x):
x = self.flatten(x)
for layer in self.my_layers:
x = layer(x)
x = self.dropout(x)
x = self.dense_2(x)
return x
if __name__ == '__main__':
input_data = tf.random.uniform([20, 28, 28])
print("Input:")
print(type(input_data))
print(input_data)
model = SequentialModel()
result = model(input_data)
print("Output:")
print(type(input_data))
print(result) The problematic expression above is
|
If I change the input file to use
|
And, the diff between the two: 7c7
< Node: synthetic < PythonLoader, Lwala/builtin/type, do()LRoot; > Context: CallStringContext: [ script A.py.do()LRoot;@122 ]
---
> Node: synthetic < PythonLoader, Lwala/builtin/type, do()LRoot; > Context: CallStringContext: [ script A.py.do()LRoot;@123 ]
13a14
> Node: synthetic < PythonLoader, L$script A.py/SequentialModel/__call__, trampoline2()LRoot; > Context: CallStringContext: [ script A.py.do()LRoot;@120 ]
14a16
> Node: <Code body of function Lscript A.py/SequentialModel/__call__> Context: CallStringContext: [ $script A.py.SequentialModel.__call__.trampoline2()LRoot;@2 ] The first difference just looks like a difference is the IR with the values, probably because there's one more value corresponding to the "new" function invocation. |
I would think that ML/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/ipa/summaries/BuiltinFunctions.java Line 288 in 1b1ffac
|
Adding tests for testing calling a method. We add four tests that include: 1. Calling model indirectly using `call` and `__call__` (2 tests) 2. Calling a model directly using `call` and `__call__` (2 tests) Related to #24
I don't think so. Specifically, |
I was able to switch the target to the correct
However,
The "receiver" is stil
The "receiver" here is: |
In the working case (test 4), by the time we hit
|
Thus, at the point of adding the "new" node, we've already know that |
The problem may have something to do with |
Ah, because this isn't a "static" method (not sure what that means for Python), |
When we get to |
__call__
doesn't show up in the call graph.The text was updated successfully, but these errors were encountered: