-
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.
Activation Converter reorg and adding tanh in aten operations
Correcting linting error correction nn_ops_converters Undoing setup.py change mistake
- Loading branch information
1 parent
f65340d
commit 13296a0
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() |