-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support tile dynamo converter (#2402)
- Loading branch information
Showing
3 changed files
with
128 additions
and
2 deletions.
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
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
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,75 @@ | ||
import torch | ||
import torch.nn as nn | ||
from parameterized import parameterized | ||
from torch.testing._internal.common_utils import run_tests | ||
|
||
from .harness import DispatchTestCase | ||
|
||
|
||
class TestTileConverter(DispatchTestCase): | ||
@parameterized.expand( | ||
[ | ||
((3,), (1,)), | ||
((3,), (0,)), | ||
((3,), (2,)), | ||
((2,), (2, 2)), | ||
((2,), (0, 2)), | ||
] | ||
) | ||
def test_tile_1D(self, shape, dims): | ||
class Tile(nn.Module): | ||
def forward(self, x): | ||
return torch.ops.aten.tile.default(x, dims) | ||
|
||
inputs = [torch.randn(shape)] | ||
self.run_test( | ||
Tile(), | ||
inputs, | ||
) | ||
|
||
@parameterized.expand( | ||
[ | ||
((3, 1), (0,)), | ||
((3, 1), (2,)), | ||
((2, 3), (2, 2)), | ||
((2, 3), (1, 0)), | ||
((2, 3), (0, 2)), | ||
((2, 3), (4, 2, 3)), | ||
((2, 3), (0, 0, 3)), | ||
((2, 3), (4, 2, 3, 1, 2)), | ||
] | ||
) | ||
def test_tile_2D(self, shape, dims): | ||
class Tile(nn.Module): | ||
def forward(self, x): | ||
return torch.ops.aten.tile.default(x, dims) | ||
|
||
inputs = [torch.randn(shape)] | ||
self.run_test( | ||
Tile(), | ||
inputs, | ||
) | ||
|
||
@parameterized.expand( | ||
[ | ||
((4, 2, 3), (2,)), | ||
((4, 2, 3), (1, 2)), | ||
((1, 2, 3), (2, 3)), | ||
((1, 2, 3), (2, 3, 4)), | ||
((1, 2, 3), (2, 3, 4, 5)), | ||
] | ||
) | ||
def test_tile_3D(self, shape, dims): | ||
class Tile(nn.Module): | ||
def forward(self, x): | ||
return torch.ops.aten.tile.default(x, dims) | ||
|
||
inputs = [torch.randn(shape)] | ||
self.run_test( | ||
Tile(), | ||
inputs, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
run_tests() |