Skip to content

switch over decorator usage of dynamo to torch.compile in tests and add inductor test #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions multipy/runtime/test_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import unittest

import torch
import torch._dynamo


class TestCompat(unittest.TestCase):
Expand All @@ -22,31 +23,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()

def fn(x, y):
a = torch.cos(x)
b = torch.sin(y)
return a + b

c_fn = torch.compile(fn, backend="ofi")
c_fn(torch.randn(10), torch.randn(10))

def test_torchdynamo_inductor(self):

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)
c_fn(torch.randn(10), torch.randn(10))


if __name__ == "__main__":
Expand Down