Skip to content

Commit

Permalink
switch over decorator usage of dynamo to torch.compile in tests and a…
Browse files Browse the repository at this point in the history
…dd inductor test (#298)

Summary: Pull Request resolved: #298

Test Plan: Imported from OSS

Reviewed By: d4l3k

Differential Revision: D42513264

Pulled By: PaliC

fbshipit-source-id: 34856568240784b1c2e1775ea46f655a9d8c13a6
  • Loading branch information
PaliC authored and facebook-github-bot committed Jan 18, 2023
1 parent cef6cac commit 19617b9
Showing 1 changed file with 20 additions and 9 deletions.
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

0 comments on commit 19617b9

Please sign in to comment.