From 2e9a48a776fef346bc5d8834b1e6c85d09acf141 Mon Sep 17 00:00:00 2001 From: Sahan Paliskara Date: Fri, 13 Jan 2023 16:02:14 -0800 Subject: [PATCH] switch over decorator usage of dynamo to torch.compile in tests and add inductor test ghstack-source-id: 88864e7358c82e38be80b03cc550d960566f0500 Pull Request resolved: https://github.com/pytorch/multipy/pull/298 --- multipy/runtime/test_compat.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/multipy/runtime/test_compat.py b/multipy/runtime/test_compat.py index 8a73db66..460beb01 100644 --- a/multipy/runtime/test_compat.py +++ b/multipy/runtime/test_compat.py @@ -7,7 +7,7 @@ import unittest import torch - +import torch._dynamo class TestCompat(unittest.TestCase): def test_torchvision(self): @@ -22,32 +22,41 @@ def test_pytorch3d(self): def test_hf_tokenizers(self): import tokenizers # noqa: F401 - @unittest.skip("torch.Library is not supported") def test_torchdynamo_eager(self): - import torch._dynamo as torchdynamo - @torchdynamo.optimize("eager") + torch._dynamo.reset() + def fn(x, y): a = torch.cos(x) b = torch.sin(y) return a + b - fn(torch.randn(10), torch.randn(10)) + c_fn = torch.compile(fn, backend="eager") + c_fn(torch.randn(10), torch.randn(10)) - @unittest.skip("torch.Library is not supported") def test_torchdynamo_ofi(self): - import torch._dynamo as torchdynamo - torchdynamo.reset() + torch._dynamo.reset() - @torchdynamo.optimize("ofi") def fn(x, y): a = torch.cos(x) b = torch.sin(y) return a + b - fn(torch.randn(10), torch.randn(10)) + c_fn = torch.compile(fn, backend="ofi") + c_fn(torch.randn(10), torch.randn(10)) + + def test_torchdynamo_inductor(self): + + torch._dynamo.reset() + + def fn(x, y): + a = torch.cos(x) + b = torch.sin(y) + return a + b + c_fn = torch.compile(fn) + c_fn(torch.randn(10), torch.randn(10)) if __name__ == "__main__": unittest.main()