MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/compiler/jit/encapsulate_util_test.cc:28–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26namespace tensorflow {
27
28TEST(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

Callers

nothing calls this directly

Calls 13

WithOpNameMethod · 0.80
ToGraphMethod · 0.80
BuildNodeNameIndexMethod · 0.80
ConstFunction · 0.70
AddClass · 0.50
IdentityFunction · 0.50
GetNodeAttrFunction · 0.50
attrsMethod · 0.45
sizeMethod · 0.45
AsProtoMethod · 0.45
dim_sizeMethod · 0.45

Tested by

no test coverage detected