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

Method test_replace_input

test/test_fx.py:2162–2175  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2160
2161
2162 def test_replace_input(self):
2163 graph : torch.fx.Graph = torch.fx.Graph()
2164 x : torch.fx.Node = graph.create_node('placeholder', 'x')
2165 y : torch.fx.Node = graph.create_node('placeholder', 'y')
2166 b : torch.fx.Node = graph.create_node('call_function', target=torch.relu, args=(x,))
2167 output : torch.fx.Node = graph.output(b)
2168
2169 b.replace_input_with(x, y)
2170
2171 gm = torch.fx.GraphModule(torch.nn.Module(), graph)
2172
2173 input_x = torch.randn(33, 44)
2174 input_y = torch.randn(11, 22)
2175 self.assertEqual(gm(input_x, input_y), torch.relu(input_y))
2176
2177 def test_insertion_point(self):
2178 graph : torch.fx.Graph = torch.fx.Graph()

Callers

nothing calls this directly

Calls 7

create_nodeMethod · 0.95
outputMethod · 0.95
replace_input_withMethod · 0.80
ModuleMethod · 0.80
randnMethod · 0.45
assertEqualMethod · 0.45
reluMethod · 0.45

Tested by

no test coverage detected