MCPcopy Create free account
hub / github.com/pytorch/pytorch / test_replace_subraph

Method test_replace_subraph

caffe2/python/nomnigraph_test.py:229–249  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

227 assert len(nn.controlFlow) == 0
228
229 def test_replace_subraph(self):
230 mg = ng.NNMatchGraph()
231 test2m = mg.createNode(ng.NeuralNetOperator("test2"), strict=True)
232 xm = mg.createNode(ng.NeuralNetData("X"), strict=True)
233 testm = mg.createNode(ng.NeuralNetOperator("test"))
234 mg.createEdge(test2m, xm)
235 mg.createEdge(xm, testm)
236
237 nn = ng.NNModule()
238 test2 = nn.dataFlow.createNode(ng.NeuralNetOperator("test2"))
239 x = nn.dataFlow.createNode(ng.NeuralNetData("X"))
240 test = nn.dataFlow.createNode(ng.NeuralNetOperator("test"))
241 nn.dataFlow.createEdge(test2, x)
242 nn.dataFlow.createEdge(x, test)
243
244 for m in nn.match(mg):
245 match = m
246 new_op = nn.dataFlow.createNode(ng.NeuralNetOperator("new_op"))
247 nn.replaceSubgraph(match, new_op, [], [])
248 assert len(nn.controlFlow) == 1
249 assert nn.controlFlow[0].name == "new_op"
250
251 def test_genericGraph(self):
252 g = ng.Graph()

Callers

nothing calls this directly

Calls 4

matchMethod · 0.95
replaceSubgraphMethod · 0.95
createNodeMethod · 0.80
createEdgeMethod · 0.80

Tested by

no test coverage detected