Skip to content

chore: Dynamic support for split (#2871) into main #2914

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
Jun 13, 2024
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
9 changes: 7 additions & 2 deletions py/torch_tensorrt/dynamo/conversion/aten_ops_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,14 +668,19 @@ def aten_ops_softmax(


@dynamo_tensorrt_converter(
torch.ops.aten.split.Tensor, capability_validator=has_static_shapes_in_args([1])
torch.ops.aten.split.Tensor,
capability_validator=has_static_shapes_in_args([1]),
supports_dynamic_shapes=True,
)
@dynamo_tensorrt_converter(
torch.ops.aten.split.sizes, capability_validator=has_static_shapes_in_args([1])
torch.ops.aten.split.sizes,
capability_validator=has_static_shapes_in_args([1]),
supports_dynamic_shapes=True,
)
@dynamo_tensorrt_converter(
torch.ops.aten.split_with_sizes.default,
capability_validator=has_static_shapes_in_args([1]),
supports_dynamic_shapes=True,
)
def aten_ops_split(
ctx: ConversionContext,
Expand Down
33 changes: 31 additions & 2 deletions tests/py/dynamo/conversion/test_split_aten.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def forward(self, input):
@parameterized.expand(
[
("select_split_size_or_sections_dim_dynamic_shape", 2, 1),
("select_split_size_or_sections_non_divisible_dim_dynamic_shape", 3, 1),
]
)
def test_split_dynamic(self, _, split_size_or_tensor, dim):
Expand All @@ -132,9 +133,37 @@ def forward(self, input):

input_specs = [
Input(
shape=(1, 10, -1),
dtype=torch.float32,
shape_ranges=[((1, 10, 1), (1, 10, 10), (1, 10, 10))],
min_shape=[1, 10, 1],
opt_shape=[1, 10, 10],
max_shape=[1, 10, 10],
),
]
self.run_test_with_dynamic_shape(
TestModule(),
input_specs,
)

@parameterized.expand(
[
("select_split_size_or_sections_dim_dynamic_shape_on_first_axis", 2, 1),
]
)
def test_split_dynamic_first_axis_dynamic(self, _, split_size_or_tensor, dim):
class TestModule(torch.nn.Module):
def __init__(self):
super().__init__()

def forward(self, input):
out = torch.ops.aten.split.Tensor(input, split_size_or_tensor, dim)
return out

input_specs = [
Input(
dtype=torch.float32,
min_shape=[1, 10, 10],
opt_shape=[3, 10, 10],
max_shape=[5, 10, 10],
),
]
self.run_test_with_dynamic_shape(
Expand Down
Loading