-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support Dynamo converter for torch.ops.aten.erf.default op
Dynamo converter support for torch.ops.aten.erf.default op
- Loading branch information
Showing
3 changed files
with
89 additions
and
3 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,52 @@ | ||
import torch | ||
import torch.nn as nn | ||
from parameterized import parameterized | ||
from torch.testing._internal.common_utils import run_tests | ||
from torch_tensorrt import Input | ||
|
||
from .harness import DispatchTestCase | ||
|
||
|
||
class TestErfConverter(DispatchTestCase): | ||
@parameterized.expand( | ||
[ | ||
("2d_dim_dtype_float", (2, 2), torch.float), | ||
("3d_dim_dtype_float", (2, 2, 2), torch.float), | ||
("2d_dim_dtype_half", (2, 2), torch.half), | ||
("3d_dim_dtype_half", (2, 2, 2), torch.half), | ||
] | ||
) | ||
def test_erf_float(self, _, x, type): | ||
class erf(nn.Module): | ||
def forward(self, input): | ||
return torch.erf(input) | ||
|
||
inputs = [torch.randn(x, dtype=type)] | ||
self.run_test( | ||
erf(), | ||
inputs, | ||
precision=type, | ||
expected_ops={torch.ops.aten.erf.default}, | ||
) | ||
|
||
@parameterized.expand( | ||
[ | ||
("2d_dim_dtype_int32", (2, 2), torch.int32, 0, 5), | ||
("3d_dim_dtype_int32", (2, 2, 2), torch.int32, 0, 5), | ||
] | ||
) | ||
def test_erf_int(self, _, x, type, min, max): | ||
class erf(nn.Module): | ||
def forward(self, input): | ||
return torch.erf(input) | ||
|
||
inputs = [torch.randint(min, max, x, dtype=type)] | ||
self.run_test( | ||
erf(), | ||
inputs, | ||
expected_ops={torch.ops.aten.erf.default}, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
run_tests() |