| 26 | namespace tensorflow { |
| 27 | |
| 28 | TEST(PerformStaticShapeInferenceBeforeEncapsulationTest, Basic) { |
| 29 | // Build the graph: |
| 30 | // "add" = "const_0" + "const_1" |
| 31 | // "identity" = "add" |
| 32 | tensorflow::Scope s = tensorflow::Scope::NewRootScope(); |
| 33 | Output const_0 = ops::Const(s.WithOpName("const_0"), 1, {2}); |
| 34 | Output const_1 = ops::Const(s.WithOpName("const_1"), 2, {2}); |
| 35 | Output add = ops::Add(s.WithOpName("add"), const_0, const_1); |
| 36 | Output identity = ops::Identity(s.WithOpName("identity"), add); |
| 37 | Graph g(OpRegistry::Global()); |
| 38 | TF_CHECK_OK(s.ToGraph(&g)); |
| 39 | |
| 40 | TF_CHECK_OK(PerformStaticShapeInferenceBeforeEncapsulation(&g)); |
| 41 | |
| 42 | // Check that "add" node now has _xla_inferred_shapes attr. |
| 43 | auto node_index = g.BuildNodeNameIndex(); |
| 44 | Node *add_node = node_index["add"]; |
| 45 | std::vector<PartialTensorShape> output_shapes; |
| 46 | TF_CHECK_OK(GetNodeAttr(add_node->attrs(), kXlaInferredShapesAttrName, |
| 47 | &output_shapes)); |
| 48 | EXPECT_EQ(output_shapes.size(), 1); |
| 49 | TensorShapeProto shape_proto; |
| 50 | output_shapes[0].AsProto(&shape_proto); |
| 51 | EXPECT_EQ(shape_proto.dim_size(), 1); |
| 52 | EXPECT_EQ(shape_proto.dim(0).size(), 2); |
| 53 | } |
| 54 | |
| 55 | } // namespace tensorflow |
nothing calls this directly
no test coverage detected