-
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.
Reorg for converters tanh (FX Converter Refactor [4/N]) <Target: conv…
…erter_reorg_proto> (#1900)
- Loading branch information
1 parent
6cd7b8f
commit c1774f9
Showing
5 changed files
with
113 additions
and
5 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
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
51 changes: 51 additions & 0 deletions
51
py/torch_tensorrt/fx/test/converters/aten_op/test_tanh_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,51 @@ | ||
import torch | ||
import torch.nn as nn | ||
from torch.testing._internal.common_utils import run_tests | ||
from torch_tensorrt.fx.tools.common_fx2trt import DispatchTestCase, InputTensorSpec | ||
|
||
|
||
class TestTanhConverter(DispatchTestCase): | ||
def test_tanh(self): | ||
class TestModule(nn.Module): | ||
def forward(self, x): | ||
return nn.functional.tanh(x) | ||
|
||
inputs = [torch.randn(1, 10)] | ||
self.run_test(TestModule(), inputs, expected_ops={torch.ops.aten.tanh.default}) | ||
|
||
def test_tanh_with_dynamic_shape(self): | ||
class TestModule(nn.Module): | ||
def forward(self, x): | ||
return nn.functional.tanh(x) | ||
|
||
input_specs = [ | ||
InputTensorSpec( | ||
shape=(-1, -1, -1), | ||
dtype=torch.float32, | ||
shape_ranges=[((1, 1, 1), (1, 2, 3), (3, 3, 3))], | ||
), | ||
] | ||
self.run_test_with_dynamic_shape( | ||
TestModule(), input_specs, expected_ops={torch.ops.aten.tanh.default} | ||
) | ||
|
||
def test_tanh_with_dynamic_shape_four_dimensions(self): | ||
class TestModule(nn.Module): | ||
def forward(self, x): | ||
return nn.functional.tanh(x) | ||
|
||
input_specs = [ | ||
InputTensorSpec( | ||
shape=(-1, -1, -1, -1), | ||
dtype=torch.float32, | ||
shape_ranges=[((1, 1, 1, 5), (1, 2, 3, 5), (3, 3, 3, 5))], | ||
), | ||
] | ||
|
||
self.run_test_with_dynamic_shape( | ||
TestModule(), input_specs, expected_ops={torch.ops.aten.tanh.default} | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
run_tests() |