mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
Repro for property related Dynamo graph break (#165609)
Signed-off-by: Edward Yang <ezyang@meta.com> Pull Request resolved: https://github.com/pytorch/pytorch/pull/165609 Approved by: https://github.com/albanD, https://github.com/gchanan, https://github.com/malfet, https://github.com/anijain2305
This commit is contained in:
committed by
PyTorch MergeBot
parent
ed74dc054d
commit
783da8b8e7
@ -5173,6 +5173,28 @@ class DefaultsTests(torch._dynamo.test_case.TestCase):
|
||||
res = opt_fn(x)
|
||||
self.assertEqual(ref, res)
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_property_class_transmute(self):
|
||||
class PropertyGetter:
|
||||
def __call__(self):
|
||||
return True
|
||||
|
||||
p = property(PropertyGetter())
|
||||
|
||||
class Mod(torch.nn.Module):
|
||||
def forward(self, x):
|
||||
if self.p:
|
||||
return x + 1
|
||||
else:
|
||||
raise RuntimeError("whoops")
|
||||
|
||||
mod = Mod()
|
||||
mod.__class__ = type(mod.__class__.__name__, (mod.__class__,), {"p": p})
|
||||
|
||||
opt_mod = torch.compile(mod, backend="eager", fullgraph=True)
|
||||
x = torch.randn(1)
|
||||
self.assertEqual(opt_mod(x), x + 1)
|
||||
|
||||
|
||||
instantiate_parametrized_tests(FunctionTests)
|
||||
instantiate_parametrized_tests(DefaultsTests)
|
||||
|
Reference in New Issue
Block a user