forked from pytorch/xla
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run decomp before processing (pytorch#5713)
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import unittest | ||
import torch | ||
import torch.nn.functional as F | ||
from torch_xla.stablehlo import exported_program_to_stablehlo | ||
|
||
|
||
class Interpolate(torch.nn.Module): | ||
|
||
def forward(self, masks: torch.Tensor) -> torch.Tensor: | ||
masks = F.interpolate( | ||
masks, | ||
size=(500, 500), | ||
mode="bilinear", | ||
align_corners=False, | ||
) | ||
return masks | ||
|
||
|
||
class ExportTest(unittest.TestCase): | ||
|
||
def test_interpolate(self): | ||
|
||
arg = (torch.randn(3, 3, 200, 200),) | ||
model = Interpolate() | ||
|
||
ans = model(*arg) | ||
|
||
with torch.no_grad(): | ||
exported = torch._export.export(model, arg) | ||
shlo = exported_program_to_stablehlo(exported) | ||
ans2 = shlo(*arg).cpu().to(torch.float32) | ||
self.assertTrue(torch.allclose(ans, ans2, atol=1e-5)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters