Skip to content

Commit 9e9b5c6

Browse files
chore: generate libraries at Wed Dec 10 20:00:55 UTC 2025
1 parent 5acd7b4 commit 9e9b5c6

1 file changed

Lines changed: 27 additions & 23 deletions

File tree

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.google.showcase.v1beta1.it;
22

3+
import static com.google.common.truth.Truth.assertThat;
4+
35
import org.junit.jupiter.api.Test;
46
import org.tensorflow.Graph;
57
import org.tensorflow.Session;
@@ -9,37 +11,39 @@
911
import org.tensorflow.proto.GraphDef;
1012
import org.tensorflow.types.TInt32;
1113

12-
import static com.google.common.truth.Truth.assertThat;
13-
// Tensorflow depends on protobuf 3.x gen code and runtime, we test it in showcase module to prove that it works with
14+
// Tensorflow depends on protobuf 3.x gen code and runtime, we test it in showcase module to prove
15+
// that it works with
1416
// protobuf 4.33+ gen code and runtime that comes with client libraries.
1517
public class ITProtobuf3Compatibility {
1618

17-
@Test
18-
void testTensorflow_helloWorldExample() {
19-
try (Graph graph = new Graph()) {
20-
// Hello world example for "10 + 32" operation.
21-
Ops tf = Ops.create(graph);
19+
@Test
20+
void testTensorflow_helloWorldExample() {
21+
try (Graph graph = new Graph()) {
22+
// Hello world example for "10 + 32" operation.
23+
Ops tf = Ops.create(graph);
2224

23-
Constant<TInt32> expectedValue1 = tf.constant(10);
24-
Constant<TInt32> expectedValue2 = tf.constant(32);
25+
Constant<TInt32> expectedValue1 = tf.constant(10);
26+
Constant<TInt32> expectedValue2 = tf.constant(32);
2527

26-
Add<TInt32> sum = tf.math.add(expectedValue1, expectedValue2);
28+
Add<TInt32> sum = tf.math.add(expectedValue1, expectedValue2);
2729

28-
try (Session s = new Session(graph)) {
29-
try (TInt32 result = (TInt32) s.runner().fetch(sum).run().get(0)) {
30-
System.out.println("10 + 32 = " + result.getInt());
31-
}
32-
}
30+
try (Session s = new Session(graph)) {
31+
try (TInt32 result = (TInt32) s.runner().fetch(sum).run().get(0)) {
32+
System.out.println("10 + 32 = " + result.getInt());
33+
}
34+
}
3335

34-
//GraphDef is a protobuf gen code.
35-
GraphDef graphDef = graph.toGraphDef();
36+
// GraphDef is a protobuf gen code.
37+
GraphDef graphDef = graph.toGraphDef();
3638

37-
//Inspect the protobuf gen code
38-
Integer actual1 = graphDef.getNode(0).getAttrOrThrow("value").getTensor().getIntValList().get(0);
39-
Integer actual2 = graphDef.getNode(1).getAttrOrThrow("value").getTensor().getIntValList().get(0);
39+
// Inspect the protobuf gen code
40+
Integer actual1 =
41+
graphDef.getNode(0).getAttrOrThrow("value").getTensor().getIntValList().get(0);
42+
Integer actual2 =
43+
graphDef.getNode(1).getAttrOrThrow("value").getTensor().getIntValList().get(0);
4044

41-
assertThat(actual1).isEqualTo(expectedValue1);
42-
assertThat(actual2).isEqualTo(expectedValue2);
43-
}
45+
assertThat(actual1).isEqualTo(expectedValue1);
46+
assertThat(actual2).isEqualTo(expectedValue2);
4447
}
48+
}
4549
}

0 commit comments

Comments
 (0)