Skip to content

Commit

Permalink
feat: support aten.atan2.out converter
Browse files Browse the repository at this point in the history
  • Loading branch information
chohk88 committed May 11, 2024
1 parent cd61e54 commit c2dc3bc
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
16 changes: 16 additions & 0 deletions py/torch_tensorrt/dynamo/conversion/aten_ops_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,22 @@ def aten_ops_atan2(
)


@dynamo_tensorrt_converter(torch.ops.aten.atan2.out)
def aten_ops_atan2_out(
ctx: ConversionContext,
target: Target,
args: Tuple[Argument, ...],
kwargs: Dict[str, Argument],
name: str,
) -> TRTTensor:
input, other = args[0], args[1]
# out = kwargs.get("out"),

out_return = impl.elementwise.atan2(ctx, target, SourceIR.ATEN, name, input, other)

return out_return


@dynamo_tensorrt_converter(torch.ops.aten.ceil.default)
def aten_ops_ceil(
ctx: ConversionContext,
Expand Down
36 changes: 36 additions & 0 deletions tests/py/dynamo/conversion/test_atan2_out_aten.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import torch
import torch.nn as nn
from parameterized import parameterized
from torch.testing._internal.common_utils import run_tests

from .harness import DispatchTestCase


class TestAtan2OutConverter(DispatchTestCase):
@parameterized.expand(
[
((10,), (5,), torch.float),
((10,), (10,), torch.float),
]
)
def test_atan2_float(self, input_shape, out_shape, dtype):
class atan2_out(nn.Module):
def forward(self, lhs_val, rhs_val, out):
return torch.ops.aten.atan2.out(lhs_val, rhs_val, out=out)

out = torch.empty(out_shape)

inputs = [
torch.randn(input_shape, dtype=dtype),
torch.randn(input_shape, dtype=dtype),
out,
]

self.run_test(
atan2_out(),
inputs,
)


if __name__ == "__main__":
run_tests()

0 comments on commit c2dc3bc

Please sign in to comment.