From b9f4b4f69bf626e308d37093e87905b1204a7c0c Mon Sep 17 00:00:00 2001 From: Meghan Lele Date: Wed, 30 Jun 2021 14:21:37 -0700 Subject: [PATCH] [JIT] Add reference semantics to TorchScript classes (#44324) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/44324 **Summary** This commit adds reference semantics to TorchScript class types; modifications made to them within TorchScript will be visible in Python. **Test Plan** This commit adds a unit test to `TestClassType` that checks that modifications made to a class type instance passed into TorchScript are visible in Python after executing the scripted function or module. **Fixes** This commit closes #41421. Test Plan: Imported from OSS Reviewed By: gmagogsfm Differential Revision: D24912807 Pulled By: SplitInfinity fbshipit-source-id: d64ac6211012425b040b987e3358253016e84ca0 --- test/test_transforms_tensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_transforms_tensor.py b/test/test_transforms_tensor.py index 2051cc7466c..84e9bd7408c 100644 --- a/test/test_transforms_tensor.py +++ b/test/test_transforms_tensor.py @@ -649,7 +649,7 @@ def test_compose(device): t = T.Compose([ lambda x: x, ]) - with pytest.raises(RuntimeError, match="Could not get name of python class object"): + with pytest.raises(RuntimeError, match="cannot call a value of type 'Tensor'"): torch.jit.script(t)