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

Method test_update_args_api

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

Source from the content-addressed store, hash-verified

2191 self.assertEqual(gm(input), torch.relu(torch.neg(input)))
2192
2193 def test_update_args_api(self):
2194 graph : torch.fx.Graph = torch.fx.Graph()
2195 x : torch.fx.Node = graph.create_node('placeholder', 'x')
2196 y : torch.fx.Node = graph.create_node('placeholder', 'y')
2197 b : torch.fx.Node = graph.create_node('call_function', target=torch.relu, args=(x,))
2198 output : torch.fx.Node = graph.output(b)
2199
2200 orig_gm = torch.fx.GraphModule(torch.nn.Module(), graph)
2201 inp_x, inp_y = torch.randn(5, 3), torch.randn(3, 5)
2202 self.assertEqual(orig_gm(inp_x, inp_y), torch.relu(inp_x))
2203
2204
2205 b.update_arg(0, y)
2206 new_gm = torch.fx.GraphModule(torch.nn.Module(), graph)
2207 self.assertEqual(new_gm(inp_x, inp_y), torch.relu(inp_y))
2208
2209 def test_update_kwargs_api(self):
2210 graph : torch.fx.Graph = torch.fx.Graph()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected