MCPcopy Create free account
hub / github.com/pytorch/tutorials / forward

Method forward

intermediate_source/torch_export_tutorial.py:200–205  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

198
199class Bad1Fixed(torch.nn.Module):
200 def forward(self, x):
201 def true_fn(x):
202 return torch.sin(x)
203 def false_fn(x):
204 return torch.cos(x)
205 return torch.cond(x.sum() > 0, true_fn, false_fn, [x])
206
207exported_bad1_fixed = export(Bad1Fixed(), (torch.randn(3, 3),))
208print(exported_bad1_fixed)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected