Skip to content

Commit 2e9a48a

Browse files
committed
switch over decorator usage of dynamo to torch.compile in tests and add inductor test
ghstack-source-id: 88864e7358c82e38be80b03cc550d960566f0500 Pull Request resolved: #298
1 parent cef6cac commit 2e9a48a

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

multipy/runtime/test_compat.py

+19-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import unittest
88

99
import torch
10-
10+
import torch._dynamo
1111

1212
class TestCompat(unittest.TestCase):
1313
def test_torchvision(self):
@@ -22,32 +22,41 @@ def test_pytorch3d(self):
2222
def test_hf_tokenizers(self):
2323
import tokenizers # noqa: F401
2424

25-
@unittest.skip("torch.Library is not supported")
2625
def test_torchdynamo_eager(self):
27-
import torch._dynamo as torchdynamo
2826

29-
@torchdynamo.optimize("eager")
27+
torch._dynamo.reset()
28+
3029
def fn(x, y):
3130
a = torch.cos(x)
3231
b = torch.sin(y)
3332
return a + b
3433

35-
fn(torch.randn(10), torch.randn(10))
34+
c_fn = torch.compile(fn, backend="eager")
35+
c_fn(torch.randn(10), torch.randn(10))
3636

37-
@unittest.skip("torch.Library is not supported")
3837
def test_torchdynamo_ofi(self):
39-
import torch._dynamo as torchdynamo
4038

41-
torchdynamo.reset()
39+
torch._dynamo.reset()
4240

43-
@torchdynamo.optimize("ofi")
4441
def fn(x, y):
4542
a = torch.cos(x)
4643
b = torch.sin(y)
4744
return a + b
4845

49-
fn(torch.randn(10), torch.randn(10))
46+
c_fn = torch.compile(fn, backend="ofi")
47+
c_fn(torch.randn(10), torch.randn(10))
48+
49+
def test_torchdynamo_inductor(self):
50+
51+
torch._dynamo.reset()
52+
53+
def fn(x, y):
54+
a = torch.cos(x)
55+
b = torch.sin(y)
56+
return a + b
5057

58+
c_fn = torch.compile(fn)
59+
c_fn(torch.randn(10), torch.randn(10))
5160

5261
if __name__ == "__main__":
5362
unittest.main()

0 commit comments

Comments
 (0)