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

Function TEST

tensorflow/compiler/jit/shape_inference_test.cc:36–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34namespace {
35
36TEST(ShapeInferenceTest, Basics) {
37 Scope root = Scope::NewRootScope().ExitOnError();
38 auto a = ops::Placeholder(root.WithOpName("A"), DT_FLOAT,
39 ops::Placeholder::Shape({2, 3}));
40 auto b = ops::Placeholder(root.WithOpName("B"), DT_FLOAT,
41 ops::Placeholder::Shape({3}));
42 auto c = ops::Placeholder(root.WithOpName("C"), DT_FLOAT);
43 auto d = ops::Add(root.WithOpName("D"), a, b);
44 auto e = ops::Add(root.WithOpName("E"), d, c);
45 auto f = ops::Neg(root.WithOpName("F"), e);
46 auto g = ops::AddN(root.WithOpName("G"), std::initializer_list<Output>{e, f});
47
48 std::unique_ptr<Graph> graph(new Graph(OpRegistry::Global()));
49 TF_CHECK_OK(root.ToGraph(graph.get()));
50
51 GraphShapeInfo shape_info;
52 TF_ASSERT_OK(InferShapes(graph.get(), /*arg_shapes=*/{},
53 /*fnlib_def=*/nullptr, &shape_info));
54
55 std::map<string, std::vector<PartialTensorShape>> expected = {
56 {"A", {PartialTensorShape({2, 3})}}, {"B", {PartialTensorShape({3})}},
57 {"C", {PartialTensorShape()}}, {"D", {PartialTensorShape({2, 3})}},
58 {"E", {PartialTensorShape()}}, {"F", {PartialTensorShape()}},
59 {"G", {PartialTensorShape()}},
60 };
61 TF_EXPECT_OK(ShapeAnnotationsMatch(*graph, shape_info, expected));
62}
63
64TEST(ShapeInferenceTest, WhileLoop) {
65 // Graph:

Callers

nothing calls this directly

Calls 15

InferShapesFunction · 0.85
PartialTensorShapeClass · 0.85
ShapeAnnotationsMatchFunction · 0.85
NextIterationFunction · 0.85
ExitOnErrorMethod · 0.80
WithOpNameMethod · 0.80
ToGraphMethod · 0.80
AsTensorShapeMethod · 0.80
PlaceholderFunction · 0.50
ShapeClass · 0.50
AddClass · 0.50
NegFunction · 0.50

Tested by

no test coverage detected