| 34 | namespace { |
| 35 | |
| 36 | TEST(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 | |
| 64 | TEST(ShapeInferenceTest, WhileLoop) { |
| 65 | // Graph: |
nothing calls this directly
no test coverage detected