-
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 aten._local_scalar_dense converter
- Loading branch information
Showing
3 changed files
with
105 additions
and
0 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
65 changes: 65 additions & 0 deletions
65
tests/py/dynamo/conversion/test_local_scalar_dense_aten.py
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,65 @@ | ||
import torch | ||
import torch.nn as nn | ||
from harness import DispatchTestCase | ||
from parameterized import parameterized | ||
from torch.testing._internal.common_utils import run_tests | ||
|
||
|
||
class TestLocalScalarDenseConverter(DispatchTestCase): | ||
@parameterized.expand( | ||
[ | ||
( | ||
torch.randn((5, 10, 5), dtype=torch.float32), | ||
), | ||
( | ||
torch.randint(-10, 10, (5, 1, 15), dtype=torch.int32), | ||
), | ||
( | ||
torch.randn((1), dtype=torch.float32), | ||
), | ||
( | ||
(torch.tensor([-2.4])), | ||
), | ||
( | ||
(torch.tensor([5.5, 3.5, 3.6])), | ||
), | ||
( | ||
(torch.tensor([True])), | ||
), | ||
( | ||
torch.tensor( | ||
[ | ||
float("nan"), | ||
1.23, | ||
float("inf"), | ||
] | ||
), | ||
), | ||
( | ||
torch.tensor( | ||
[ | ||
float("-inf"), | ||
1.23, | ||
float("nan"), | ||
] | ||
), | ||
), | ||
( | ||
(torch.tensor([float("inf")])), | ||
), | ||
] | ||
) | ||
def test_local_scalar_dense(self, data): | ||
class local_scalar_dense(nn.Module): | ||
def forward(self, input): | ||
return torch.ops.aten._local_scalar_dense.default(input) | ||
|
||
inputs = [data] | ||
self.run_test( | ||
local_scalar_dense(), | ||
inputs, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
run_tests() |