Skip to content
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
4 changes: 2 additions & 2 deletions py/torch_tensorrt/dynamo/conversion/aten_ops_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ def aten_ops_log1p(
)


@dynamo_tensorrt_converter(torch.ops.aten.sqrt.default)
@dynamo_tensorrt_converter(torch.ops.aten.sqrt.default, supports_dynamic_shapes=True)
def aten_ops_sqrt(
ctx: ConversionContext,
target: Target,
Expand Down Expand Up @@ -2920,7 +2920,7 @@ def aten_ops_trunc(
)


@dynamo_tensorrt_converter(torch.ops.aten.copy.default)
@dynamo_tensorrt_converter(torch.ops.aten.copy.default, supports_dynamic_shapes=True)
@enforce_tensor_types(
{
1: (TRTTensor,),
Expand Down
62 changes: 62 additions & 0 deletions tests/py/dynamo/conversion/test_copy_aten.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import torch.nn as nn
from parameterized import parameterized
from torch.testing._internal.common_utils import run_tests
from torch_tensorrt import Input

from .harness import DispatchTestCase

Expand All @@ -26,6 +27,67 @@ def forward(self, input, src):
inputs,
)

@parameterized.expand(
[
(
"1d_float32",
torch.float32,
(1,),
(2,),
(3,),
False,
),
(
"2d_float32",
torch.float32,
(1, 1),
(2, 2),
(3, 3),
False,
),
(
"3d_float32",
torch.float32,
(1, 1, 1),
(2, 2, 2),
(3, 3, 3),
True,
),
(
"4d_float32",
torch.float32,
(1, 1, 1, 1),
(2, 2, 2, 2),
(3, 3, 3, 3),
True,
),
]
)
def test_dynamic_shape_copy_float(self, *args):
class Copy(nn.Module):
def forward(self, input, src):
return torch.ops.aten.copy.default(input, src, args[5])

input_specs = [
Input(
min_shape=args[2],
opt_shape=args[3],
max_shape=args[4],
dtype=args[1],
),
Input(
min_shape=args[2],
opt_shape=args[3],
max_shape=args[4],
dtype=args[1],
),
]

self.run_test_with_dynamic_shape(
Copy(),
input_specs,
)


if __name__ == "__main__":
run_tests()
95 changes: 95 additions & 0 deletions tests/py/dynamo/conversion/test_sqrt_aten.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import torch.nn as nn
from parameterized import parameterized
from torch.testing._internal.common_utils import run_tests
from torch_tensorrt import Input

from .harness import DispatchTestCase

Expand Down Expand Up @@ -44,6 +45,100 @@ def forward(self, input):
inputs,
)

@parameterized.expand(
[
(
"1d_float32",
torch.float32,
(1,),
(2,),
(3,),
),
(
"2d_float32",
torch.float32,
(1, 1),
(2, 2),
(3, 3),
),
(
"3d_float32",
torch.float32,
(1, 1, 1),
(2, 2, 2),
(3, 3, 3),
),
(
"4d_float32",
torch.float32,
(1, 1, 1, 1),
(2, 2, 2, 2),
(3, 3, 3, 3),
),
]
)
def test_dynamic_shape_sqrt_float(self, *args):
class sqrt(nn.Module):
def forward(self, input):
return torch.ops.aten.sqrt.default(input)

input_specs = [
Input(
min_shape=args[2],
opt_shape=args[3],
max_shape=args[4],
dtype=args[1],
),
]
self.run_test_with_dynamic_shape(sqrt(), input_specs)

@parameterized.expand(
[
(
"1d_int32",
torch.int,
(1,),
(2,),
(3,),
),
(
"2d_int32",
torch.int32,
(1, 1),
(2, 2),
(3, 3),
),
(
"3d_int32",
torch.int,
(1, 1, 1),
(2, 2, 2),
(3, 3, 3),
),
(
"4d_int32",
torch.int32,
(1, 1, 1, 1),
(2, 2, 2, 2),
(3, 3, 3, 3),
),
]
)
def test_dynamic_shape_sqrt_int(self, *args):
class sqrt(nn.Module):
def forward(self, input):
return torch.ops.aten.sqrt.default(input)

input_specs = [
Input(
min_shape=args[2],
opt_shape=args[3],
max_shape=args[4],
dtype=args[1],
),
]
self.run_test_with_dynamic_shape(sqrt(), input_specs)


if __name__ == "__main__":
run_tests()