Skip to content

fix: Move aten.neg test case #2310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions py/torch_tensorrt/dynamo/conversion/impl/unary/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,11 @@ def neg(
name: str,
input_val: TRTTensor,
) -> TRTTensor:
if (isinstance(input_val, TRTTensor)) and (
input_val.dtype == trt.int8 or input_val.dtype == trt.int32
):
input_val = cast_trt_tensor(network, input_val, trt.float32, name)

return convert_unary(
network, target, source_ir, name, trt.UnaryOperation.NEG, input_val
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from parameterized import parameterized
from torch.testing._internal.common_utils import run_tests
from torch_tensorrt import Input
from torch_tensorrt.dynamo.test_utils import DispatchTestCase

from .harness import DispatchTestCase


class TestNegConverter(DispatchTestCase):
Expand Down Expand Up @@ -43,8 +44,8 @@ def forward(self, input):
self.run_test(
neg(),
inputs,
output_dtypes=[torch.int32],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output dtype will not agree with the casted output dtype unless another cast is inserted to "undo" the initial cast. Here, for example, if the input is torch.int32, the output will be torch.float.

expected_ops={torch.ops.aten.neg.default},
check_dtype=False,
)


Expand Down