Skip to content

Commit 20b4418

Browse files
author
Tatiana Castro-Vélez
authored
Merge branch 'main' into 139-missing-tffunction-parameters
2 parents cbfd513 + 20e28c2 commit 20b4418

File tree

11 files changed

+188
-17
lines changed

11 files changed

+188
-17
lines changed

edu.cuny.hunter.hybridize.core/META-INF/MANIFEST.MF

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ Require-Bundle: org.eclipse.ltk.core.refactoring;bundle-version="3.12.200",
1111
edu.cuny.citytech.refactoring.common.core;bundle-version="3.1.0",
1212
org.eclipse.equinox.registry;bundle-version="3.11.100",
1313
org.eclipse.osgi;bundle-version="3.18.0",
14-
org.python.pydev.parser;bundle-version="9.3.2",
15-
org.python.pydev.core;bundle-version="9.3.2",
16-
org.python.pydev.ast;bundle-version="9.3.2",
17-
com.python.pydev.refactoring,
18-
com.python.pydev.analysis,
14+
org.python.pydev.parser;bundle-version="[9.3.2,10.0.0)",
15+
org.python.pydev.core;bundle-version="[9.3.2,10.0.0)",
16+
org.python.pydev.ast;bundle-version="[9.3.2,10.0.0)",
17+
com.python.pydev.refactoring;bundle-version="[9.3.2,10.0.0)",
18+
com.python.pydev.analysis;bundle-version="[9.3.2,10.0.0)",
1919
org.eclipse.core.resources;bundle-version="3.18.0"
2020
Import-Package: org.eclipse.core.runtime;version="3.7.0",
2121
org.eclipse.jface.text,

edu.cuny.hunter.hybridize.tests/META-INF/MANIFEST.MF

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ Automatic-Module-Name: edu.cuny.hunter.hybridize.tests
99
Bundle-RequiredExecutionEnvironment: JavaSE-11
1010
Require-Bundle: edu.cuny.citytech.refactoring.common.tests;bundle-version="3.1.0",
1111
org.eclipse.jdt.ui.tests.refactoring;bundle-version="3.14.300",
12-
org.python.pydev;bundle-version="9.3.2",
12+
org.python.pydev;bundle-version="[9.3.2,10.0.0)",
1313
org.junit;bundle-version="4.13.2",
1414
org.eclipse.ltk.core.refactoring;bundle-version="3.12.200",
1515
org.eclipse.jface.text;bundle-version="3.20.100",
1616
org.eclipse.core.runtime;bundle-version="3.25.0",
17-
org.python.pydev.parser;bundle-version="9.3.2",
18-
org.python.pydev.core;bundle-version="9.3.2",
17+
org.python.pydev.parser;bundle-version="[9.3.2,10.0.0)",
18+
org.python.pydev.core;bundle-version="[9.3.2,10.0.0)",
1919
edu.cuny.hunter.hybridize.core;bundle-version="1.0.0",
2020
edu.cuny.citytech.refactoring.common.core;bundle-version="3.0.0",
21-
org.python.pydev.ast,
22-
org.python.pydev.refactoring
21+
org.python.pydev.ast;bundle-version="[9.3.2,10.0.0)",
22+
org.python.pydev.refactoring;bundle-version="[9.3.2,10.0.0)"
2323
Export-Package: edu.cuny.hunter.hybridize.tests
2424
Import-Package: com.python.pydev.analysis.additionalinfo,
2525
org.eclipse.core.resources,

edu.cuny.hunter.hybridize.tests/resources/HybridizeFunction/testModel/in/A.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, **kwargs):
1616
self.dropout = tf.keras.layers.Dropout(0.2)
1717
self.dense_2 = tf.keras.layers.Dense(10)
1818

19-
def call(self, x):
19+
def __call__(self, x):
2020
x = self.flatten(x)
2121

2222
for layer in self.my_layers:
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import tensorflow as tf
2+
3+
# Create an override model to classify pictures
4+
5+
class SequentialModel(tf.keras.Model):
6+
def __init__(self, **kwargs):
7+
super(SequentialModel, self).__init__(**kwargs)
8+
9+
self.flatten = tf.keras.layers.Flatten(input_shape=(28, 28))
10+
11+
# Add a lot of small layers
12+
num_layers = 100
13+
self.my_layers = [tf.keras.layers.Dense(64, activation="relu")
14+
for n in range(num_layers)]
15+
16+
self.dropout = tf.keras.layers.Dropout(0.2)
17+
self.dense_2 = tf.keras.layers.Dense(10)
18+
19+
def call(self, x):
20+
x = self.flatten(x)
21+
22+
for layer in self.my_layers:
23+
x = layer(x)
24+
25+
x = self.dropout(x)
26+
x = self.dense_2(x)
27+
28+
return x
29+
30+
if __name__ == '__main__':
31+
input_data = tf.random.uniform([20, 28, 28])
32+
print("Input:")
33+
print(type(input_data))
34+
print(input_data)
35+
36+
model = SequentialModel()
37+
result = model(input_data)
38+
39+
print("Output:")
40+
print(type(input_data))
41+
print(result)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tensorflow==2.9.3
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import tensorflow as tf
2+
3+
# Create an override model to classify pictures
4+
5+
class SequentialModel(tf.keras.Model):
6+
def __init__(self, **kwargs):
7+
super(SequentialModel, self).__init__(**kwargs)
8+
9+
self.flatten = tf.keras.layers.Flatten(input_shape=(28, 28))
10+
11+
# Add a lot of small layers
12+
num_layers = 100
13+
self.my_layers = [tf.keras.layers.Dense(64, activation="relu")
14+
for n in range(num_layers)]
15+
16+
self.dropout = tf.keras.layers.Dropout(0.2)
17+
self.dense_2 = tf.keras.layers.Dense(10)
18+
19+
def call(self, x):
20+
x = self.flatten(x)
21+
22+
for layer in self.my_layers:
23+
x = layer(x)
24+
25+
x = self.dropout(x)
26+
x = self.dense_2(x)
27+
28+
return x
29+
30+
if __name__ == '__main__':
31+
input_data = tf.random.uniform([20, 28, 28])
32+
print("Input:")
33+
print(type(input_data))
34+
print(input_data)
35+
36+
model = SequentialModel()
37+
result = model.call(input_data)
38+
39+
print("Output:")
40+
print(type(input_data))
41+
print(result)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tensorflow==2.9.3
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import tensorflow as tf
2+
3+
# Create an override model to classify pictures
4+
5+
class SequentialModel(tf.keras.Model):
6+
def __init__(self, **kwargs):
7+
super(SequentialModel, self).__init__(**kwargs)
8+
9+
self.flatten = tf.keras.layers.Flatten(input_shape=(28, 28))
10+
11+
# Add a lot of small layers
12+
num_layers = 100
13+
self.my_layers = [tf.keras.layers.Dense(64, activation="relu")
14+
for n in range(num_layers)]
15+
16+
self.dropout = tf.keras.layers.Dropout(0.2)
17+
self.dense_2 = tf.keras.layers.Dense(10)
18+
19+
def __call__(self, x):
20+
x = self.flatten(x)
21+
22+
for layer in self.my_layers:
23+
x = layer(x)
24+
25+
x = self.dropout(x)
26+
x = self.dense_2(x)
27+
28+
return x
29+
30+
if __name__ == '__main__':
31+
input_data = tf.random.uniform([20, 28, 28])
32+
print("Input:")
33+
print(type(input_data))
34+
print(input_data)
35+
36+
model = SequentialModel()
37+
result = model.__call__(input_data)
38+
39+
print("Output:")
40+
print(type(input_data))
41+
print(result)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tensorflow==2.9.3

edu.cuny.hunter.hybridize.tests/test cases/edu/cuny/hunter/hybridize/tests/HybridizeFunctionRefactoringTest.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,4 +1619,49 @@ public void testModel() throws Exception {
16191619
// no hybrids.
16201620
assertTrue(functions.stream().map(Function::isHybrid).allMatch(b -> b == false));
16211621
}
1622+
1623+
/**
1624+
* Test a model. No tf.function in this one. Use call instead of __call__. Ariadne doesn't support __call__.
1625+
* See https://github.com/wala/ML/issues/24.
1626+
*/
1627+
@Test
1628+
public void testModel2() throws Exception {
1629+
Set<Function> functions = this.getFunctions();
1630+
assertNotNull(functions);
1631+
1632+
LOG.info("Found functions: " + functions.size());
1633+
1634+
// no hybrids.
1635+
assertTrue(functions.stream().map(Function::isHybrid).allMatch(b -> b == false));
1636+
}
1637+
1638+
/**
1639+
* Test a model. No tf.function in this one. Explicit call method.
1640+
*/
1641+
@Test
1642+
public void testModel3() throws Exception {
1643+
Set<Function> functions = this.getFunctions();
1644+
assertNotNull(functions);
1645+
1646+
LOG.info("Found functions: " + functions.size());
1647+
1648+
// no hybrids.
1649+
assertTrue(functions.stream().map(Function::isHybrid).allMatch(b -> b == false));
1650+
}
1651+
1652+
/**
1653+
* Test a model. No tf.function in this one. Explicit call method.
1654+
*/
1655+
@Test
1656+
public void testModel4() throws Exception {
1657+
Set<Function> functions = this.getFunctions();
1658+
assertNotNull(functions);
1659+
1660+
LOG.info("Found functions: " + functions.size());
1661+
1662+
// no hybrids.
1663+
assertTrue(functions.stream().map(Function::isHybrid).allMatch(b -> b == false));
1664+
}
1665+
1666+
// TODO: Test models that have tf.functions.
16221667
}

0 commit comments

Comments
 (0)