Skip to content

Commit 1505689

Browse files
committed
Add pretty printing.
1 parent b3f9437 commit 1505689

File tree

10 files changed

+75
-0
lines changed

10 files changed

+75
-0
lines changed

com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/client/Constant.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
public class Constant extends TensorGenerator {
1919

20+
private static final String FUNCTION_NAME = "tf.constant()";
21+
2022
private static final int VALUE_NUMBER_FOR_VALUE_ARGUMENT = 2;
2123

2224
private static final int VALUE_NUMBER_FOR_DTYPE_ARGUMENT = 3;
@@ -57,4 +59,9 @@ protected int getValueNumberForShapeArgument() {
5759
// function's name).
5860
return VALUE_NUMBER_FOR_SHAPE_ARGUMENT;
5961
}
62+
63+
@Override
64+
protected String getSignature() {
65+
return FUNCTION_NAME;
66+
}
6067
}

com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/client/Fill.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
public class Fill extends Constant {
1717

18+
private static final String FUNCTION_NAME = "tf.fill()";
19+
1820
private static final int VALUE_NUMBER_FOR_SHAPE_ARGUMENT = 2;
1921

2022
private static final int VALUE_NUMBER_FOR_VALUE_ARGUMENT = 3;
@@ -48,4 +50,9 @@ protected int getValueNumberForShapeArgument() {
4850
protected Set<List<Dimension<?>>> getDefaultShapes(PropagationCallGraphBuilder builder) {
4951
throw new UnsupportedOperationException("Shape is mandatory and must be provided explicitly.");
5052
}
53+
54+
@Override
55+
protected String getSignature() {
56+
return FUNCTION_NAME;
57+
}
5158
}

com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/client/Normal.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212
*/
1313
public class Normal extends Uniform {
1414

15+
private static final String FUNCTION_NAME = "tf.random.normal()";
16+
1517
public Normal(PointsToSetVariable source, CGNode node) {
1618
super(source, node);
1719
}
20+
21+
@Override
22+
protected String getSignature() {
23+
return FUNCTION_NAME;
24+
}
1825
}

com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/client/Ones.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class Ones extends TensorGenerator {
2222

2323
private static final java.util.logging.Logger LOGGER = getLogger(Ones.class.getName());
2424

25+
private static final String FUNCTION_NAME = "tf.ones()";
26+
2527
private static final int VALUE_NUMBER_FOR_SHAPE_ARGUMENT = 2;
2628

2729
private static final int VALUE_NUMBER_FOR_DTYPE_ARGUMENT = 3;
@@ -53,4 +55,9 @@ protected int getValueNumberForShapeArgument() {
5355
protected int getValueNumberForDTypeArgument() {
5456
return VALUE_NUMBER_FOR_DTYPE_ARGUMENT;
5557
}
58+
59+
@Override
60+
protected String getSignature() {
61+
return FUNCTION_NAME;
62+
}
5663
}

com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/client/Range.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public class Range extends TensorGenerator {
4141

4242
private static final Logger LOGGER = Logger.getLogger(Range.class.getName());
4343

44+
private static final String FUNCTION_NAME = "tf.range()";
45+
4446
public Range(PointsToSetVariable source, CGNode node) {
4547
super(source, node);
4648
}
@@ -212,4 +214,9 @@ protected int getValueNumberForDTypeArgument() {
212214

213215
return -1; // Positional dtype argument for range() is not yet implemented.
214216
}
217+
218+
@Override
219+
protected String getSignature() {
220+
return FUNCTION_NAME;
221+
}
215222
}

com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/client/TensorGenerator.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,4 +589,16 @@ private EnumSet<DType> getDTypesOfValue(
589589
protected CGNode getNode() {
590590
return this.node;
591591
}
592+
593+
@Override
594+
public String toString() {
595+
return this.getSignature();
596+
}
597+
598+
/**
599+
* Returns the TensorFlow function signature represented by this generator.
600+
*
601+
* @return The TensorFlow function signature represented by this generator.
602+
*/
603+
protected abstract String getSignature();
592604
}

com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/client/TruncatedNormal.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@
1313
*/
1414
public class TruncatedNormal extends Normal {
1515

16+
private static final String FUNCTION_NAME = "tf.random.truncated_normal()";
17+
1618
public TruncatedNormal(PointsToSetVariable source, CGNode node) {
1719
super(source, node);
1820
// TODO Auto-generated constructor stub
1921
}
22+
23+
@Override
24+
protected String getSignature() {
25+
return FUNCTION_NAME;
26+
}
2027
}

com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/client/Uniform.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
*/
1313
public class Uniform extends Ones {
1414

15+
private static final String FUNCTION_NAME = "tf.random.uniform()";
16+
1517
private static final int VALUE_NUMBER_FOR_DTYPE_ARGUMENT = 5;
1618

1719
public Uniform(PointsToSetVariable source, CGNode node) {
@@ -22,4 +24,9 @@ public Uniform(PointsToSetVariable source, CGNode node) {
2224
protected int getValueNumberForDTypeArgument() {
2325
return VALUE_NUMBER_FOR_DTYPE_ARGUMENT;
2426
}
27+
28+
@Override
29+
protected String getSignature() {
30+
return FUNCTION_NAME;
31+
}
2532
}

com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/client/Zeros.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@
1111
*/
1212
public class Zeros extends Ones {
1313

14+
private static final String FUNCTION_NAME = "tf.zeros()";
15+
1416
public Zeros(PointsToSetVariable source, CGNode node) {
1517
super(source, node);
1618
}
19+
20+
@Override
21+
protected String getSignature() {
22+
return FUNCTION_NAME;
23+
}
1724
}

com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/client/ZerosLike.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
*/
1313
public class ZerosLike extends Constant {
1414

15+
public static final String FUNCTION_NAME = "tf.zeros_like()";
16+
1517
/**
1618
* The shape argument is not explicitly provided to zeros_like(); rather, the shape is inferred
1719
* from the `input` argument.
@@ -26,4 +28,9 @@ public ZerosLike(PointsToSetVariable source, CGNode node) {
2628
protected int getValueNumberForShapeArgument() {
2729
return VALUE_NUMBER_FOR_SHAPE_ARGUMENT;
2830
}
31+
32+
@Override
33+
protected String getSignature() {
34+
return FUNCTION_NAME;
35+
}
2936
}

0 commit comments

Comments
 (0)