提交 265b498d 编写于 作者: Michael Suo's avatar Michael Suo 提交者: Facebook Github Bot

add a test for inline tracing

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/23535

Test Plan: Imported from OSS

Differential Revision: D16554694

Pulled By: suo

fbshipit-source-id: 0fae4458f18c06ffbd484905ad7836dce9ce69cc
上级 52b95fd4
......@@ -329,6 +329,22 @@ class TestJit(JitTestCase):
t2 = torch.rand(3, 4)
self.assertEqual(r(t2), m.x + t2)
def test_trace_nested_fn(self):
class TracedInlineDecision(torch.nn.Module):
def forward(self, x, flag):
@torch.jit.script
def make_decision(flag, x):
if flag:
return x
else:
return torch.zeros_like(x)
x = torch.neg(x) # do something random
return make_decision(flag, x)
decision = TracedInlineDecision()
torch.jit.trace(decision, (torch.rand(3, 4), torch.tensor([True], dtype=torch.bool)), check_trace=True)
def test_restore_device(self):
# main purpose is checking map_location works
m = torch.jit.ScriptModule()
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册