Skip to content

Commit

Permalink
feat: support aten.atan2.out converter (#2829)
Browse files Browse the repository at this point in the history
  • Loading branch information
chohk88 committed May 24, 2024
1 parent fef02b7 commit 32ffae8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 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 @@ -1533,6 +1533,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
30 changes: 28 additions & 2 deletions tests/py/dynamo/conversion/test_atan2_aten.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def forward(self, lhs_val, rhs_val):
]
)
def test_atan2_zero(self, dtype, x_val, y_val):
class Atan2(nn.Module):
class atan2(nn.Module):
def forward(self, lhs_val, rhs_val):
return torch.ops.aten.atan2.default(lhs_val, rhs_val)

Expand All @@ -123,7 +123,33 @@ def forward(self, lhs_val, rhs_val):
]

self.run_test(
Atan2(),
atan2(),
inputs,
)


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,
)

Expand Down

0 comments on commit 32ffae8

Please sign in to comment.