| 26 | namespace processor { |
| 27 | |
| 28 | TEST(GraphOptimizerTest, StaticShapeCluteringStrategy0) { |
| 29 | GraphDef graph_def; |
| 30 | NodeDef* n0 = graph_def.add_node(); |
| 31 | n0->set_name("A"); |
| 32 | n0->set_op("A"); |
| 33 | AttrValue value0; |
| 34 | tensorflow::TensorShapeProto tshape0; |
| 35 | tshape0.add_dim()->set_size(-1); |
| 36 | *value0.mutable_shape() = tshape0; |
| 37 | (*n0->mutable_attr())["_output_shapes"] = value0; |
| 38 | |
| 39 | NodeDef* n1 = graph_def.add_node(); |
| 40 | n1->set_name("B"); |
| 41 | n1->set_op("B"); |
| 42 | AttrValue value1; |
| 43 | tensorflow::TensorShapeProto tshape1; |
| 44 | tshape1.add_dim()->set_size(1); |
| 45 | *value1.mutable_shape() = tshape1; |
| 46 | (*n1->mutable_attr())["_output_shapes"] = value1; |
| 47 | |
| 48 | NodeDef* n2 = graph_def.add_node(); |
| 49 | n2->set_name("C"); |
| 50 | n2->set_op("C"); |
| 51 | AttrValue value2; |
| 52 | tensorflow::TensorShapeProto tshape2; |
| 53 | tshape2.add_dim()->set_size(1); |
| 54 | *value2.mutable_shape() = tshape2; |
| 55 | (*n2->mutable_attr())["_output_shapes"] = value2; |
| 56 | |
| 57 | NodeDef* n3 = graph_def.add_node(); |
| 58 | n3->set_name("D"); |
| 59 | n3->set_op("D"); |
| 60 | AttrValue value3; |
| 61 | tensorflow::TensorShapeProto tshape3; |
| 62 | tshape3.add_dim()->set_size(1); |
| 63 | *value3.mutable_shape() = tshape3; |
| 64 | (*n3->mutable_attr())["_output_shapes"] = value3; |
| 65 | |
| 66 | n2->add_input("A"); |
| 67 | n2->add_input("B"); |
| 68 | n3->add_input("C"); |
| 69 | |
| 70 | StaticShapeCluteringStrategy sscs; |
| 71 | std::vector<std::string> inputs; |
| 72 | inputs.push_back("A"); |
| 73 | inputs.push_back("B"); |
| 74 | std::vector<std::string> outputs; |
| 75 | outputs.push_back("D"); |
| 76 | ClusteredGraphInfo clustered_graph_info; |
| 77 | |
| 78 | sscs.Run(graph_def, inputs, outputs, &clustered_graph_info); |
| 79 | |
| 80 | // graphdef1 |
| 81 | GraphDef gdef1 = clustered_graph_info.tf_subgraph; |
| 82 | EXPECT_EQ(gdef1.node().size(), 3); |
| 83 | int count = 3; |
| 84 | for (auto node : gdef1.node()) { |
| 85 | if (node.name() == "A" || |
nothing calls this directly
no test coverage detected