| 142 | } |
| 143 | |
| 144 | TEST(MutableGraphViewTest, AddSubgraph) { |
| 145 | GraphDef graph_def = test::function::GDef( |
| 146 | { |
| 147 | NDef("foo", "NotImportant", {}, {}), |
| 148 | NDef("bar", "NotImportant", {}, {}), |
| 149 | NDef("baz", "NotImportant", {"foo", "bar"}), |
| 150 | }, |
| 151 | /*funcs=*/{}); |
| 152 | MutableGraphView graph(&graph_def); |
| 153 | |
| 154 | // `s/bar` node has inputs that are valid only if we add subgraph into the |
| 155 | // original graph. |
| 156 | GraphDef subgraph = test::function::GDef( |
| 157 | { |
| 158 | NDef("s/n0", "NotImportant", {}, {}), |
| 159 | NDef("s/n1", "NotImportant", {"bar", "s/n0"}, {}), |
| 160 | }, |
| 161 | /*funcs=*/{}); |
| 162 | |
| 163 | TF_EXPECT_OK(graph.AddSubgraph(std::move(subgraph))); |
| 164 | |
| 165 | // Fanins and fanouts must be updated for the nodes of the original graph, and |
| 166 | // added subgraph. |
| 167 | CheckNode(graph, "bar", "NotImportant", "", {}, {}, {"baz:1", "s/n1"}); |
| 168 | CheckNode(graph, "s/n1", "NotImportant", "", {}, {"bar", "s/n0"}, {}); |
| 169 | CheckGraph(graph); |
| 170 | } |
| 171 | |
| 172 | TEST(MutableGraphViewTest, AddSubgraphAndAddFunction) { |
| 173 | GraphDef graph_def; |
nothing calls this directly
no test coverage detected