forked from wala/ML
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deal with multiple possible callables (#121)
* Return `null` when there are multiple possible callables. * Add test to exercise call string imprecision. Based on the call string length. See wala/WALA#1417 (reply in thread). * Expect the test to fail. In the past, we could add 0's to the parameters, but since we are not enforcing the existing of the node in the CG, we can no longer do that. Still, this test should now fail if wala#207 is fixed.
- Loading branch information
Showing
7 changed files
with
157 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
9 changes: 9 additions & 0 deletions
9
com.ibm.wala.cast.python.test/data/proj66/src/tf2_test_model_call5b.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Test https://github.com/wala/WALA/discussions/1417#discussioncomment-10085680. | ||
|
||
|
||
def f(m, d): | ||
return m.predict(d) | ||
|
||
|
||
def g(m, d): | ||
return f(m, d) |
44 changes: 44 additions & 0 deletions
44
com.ibm.wala.cast.python.test/data/proj66/tf2_test_model_call5.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Test https://github.com/wala/WALA/discussions/1417#discussioncomment-10085680. | ||
|
||
import tensorflow as tf | ||
from src.tf2_test_model_call5b import g | ||
|
||
# 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): | ||
print("Raffi 1") | ||
x = self.flatten(x) | ||
|
||
for layer in self.my_layers: | ||
x = layer(x) | ||
|
||
x = self.dropout(x) | ||
x = self.dense_2(x) | ||
|
||
return x | ||
|
||
def predict(self, x): | ||
return self(x) | ||
|
||
|
||
input_data = tf.random.uniform([20, 28, 28]) | ||
|
||
model = SequentialModel() | ||
result = g(model, input_data) |
44 changes: 44 additions & 0 deletions
44
com.ibm.wala.cast.python.test/data/proj66/tf2_test_model_call5a.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Test https://github.com/wala/WALA/discussions/1417#discussioncomment-10085680. | ||
|
||
import tensorflow as tf | ||
from src.tf2_test_model_call5b import g | ||
|
||
# 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): | ||
print("Raffi 2") | ||
x = self.flatten(x) | ||
|
||
for layer in self.my_layers: | ||
x = layer(x) | ||
|
||
x = self.dropout(x) | ||
x = self.dense_2(x) | ||
|
||
return x | ||
|
||
def predict(self, x): | ||
return self(x) | ||
|
||
|
||
input_data = tf.random.uniform([20, 28, 28]) | ||
|
||
model = SequentialModel() | ||
result = g(model, input_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters