Skip to content
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

Add dynamic shape support for leaky_relu/elu/hard_sigmoid/softplus #2927

Merged
merged 1 commit into from
Jun 17, 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
14 changes: 10 additions & 4 deletions py/torch_tensorrt/dynamo/conversion/aten_ops_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,9 @@ def aten_ops_tanh(
)


@dynamo_tensorrt_converter(torch.ops.aten.leaky_relu.default)
@dynamo_tensorrt_converter(
torch.ops.aten.leaky_relu.default, supports_dynamic_shapes=True
)
def aten_ops_leaky_relu(
ctx: ConversionContext,
target: Target,
Expand All @@ -477,7 +479,7 @@ def aten_ops_leaky_relu(
)


@dynamo_tensorrt_converter(torch.ops.aten.elu.default)
@dynamo_tensorrt_converter(torch.ops.aten.elu.default, supports_dynamic_shapes=True)
def aten_ops_elu(
ctx: ConversionContext,
target: Target,
Expand All @@ -496,7 +498,9 @@ def aten_ops_elu(
)


@dynamo_tensorrt_converter(torch.ops.aten.softplus.default)
@dynamo_tensorrt_converter(
torch.ops.aten.softplus.default, supports_dynamic_shapes=True
)
def aten_ops_softplus(
ctx: ConversionContext,
target: Target,
Expand All @@ -514,7 +518,9 @@ def aten_ops_softplus(
)


@dynamo_tensorrt_converter(torch.ops.aten.hardsigmoid.default)
@dynamo_tensorrt_converter(
torch.ops.aten.hardsigmoid.default, supports_dynamic_shapes=True
)
def aten_ops_hard_sigmoid(
ctx: ConversionContext,
target: Target,
Expand Down
10 changes: 6 additions & 4 deletions tests/py/dynamo/conversion/test_elu_aten.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ def forward(self, x):

input_specs = [
Input(
shape=(-1, -1, -1),
dtype=torch.float32,
shape_ranges=[((1, 1, 1), (1, 2, 3), (3, 3, 3))],
min_shape=(1, 1, 1),
opt_shape=(1, 2, 3),
max_shape=(3, 3, 3),
),
]
self.run_test_with_dynamic_shape(TestModule(), input_specs)
Expand All @@ -36,9 +37,10 @@ def forward(self, x):

input_specs = [
Input(
shape=(-1, -1, -1, -1),
dtype=torch.float32,
shape_ranges=[((1, 1, 1, 5), (1, 2, 3, 5), (3, 3, 3, 5))],
min_shape=(1, 1, 1, 5),
opt_shape=(1, 2, 3, 5),
max_shape=(3, 3, 3, 5),
),
]

Expand Down
10 changes: 6 additions & 4 deletions tests/py/dynamo/conversion/test_hard_sigmoid_aten.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ def forward(self, x):

input_specs = [
Input(
shape=(-1, -1, -1),
dtype=torch.float32,
shape_ranges=[((1, 1, 1), (1, 2, 3), (3, 3, 3))],
min_shape=(1, 1, 1),
opt_shape=(1, 2, 3),
max_shape=(3, 3, 3),
),
]
self.run_test_with_dynamic_shape(TestModule(), input_specs)
Expand All @@ -36,9 +37,10 @@ def forward(self, x):

input_specs = [
Input(
shape=(-1, -1, -1, -1),
dtype=torch.float32,
shape_ranges=[((1, 1, 1, 5), (1, 2, 3, 5), (3, 3, 3, 5))],
min_shape=(1, 1, 1, 5),
opt_shape=(1, 2, 3, 5),
max_shape=(3, 3, 3, 5),
),
]

Expand Down
10 changes: 6 additions & 4 deletions tests/py/dynamo/conversion/test_leaky_relu_aten.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ def forward(self, x):

input_specs = [
Input(
shape=(-1, -1, -1),
dtype=torch.float32,
shape_ranges=[((1, 1, 1), (1, 2, 3), (3, 3, 3))],
min_shape=(1, 1, 1),
opt_shape=(1, 2, 3),
max_shape=(3, 3, 3),
),
]
self.run_test_with_dynamic_shape(TestModule(), input_specs)
Expand All @@ -36,9 +37,10 @@ def forward(self, x):

input_specs = [
Input(
shape=(-1, -1, -1, -1),
dtype=torch.float32,
shape_ranges=[((1, 1, 1, 5), (1, 2, 3, 5), (3, 3, 3, 5))],
min_shape=(1, 1, 1, 5),
opt_shape=(1, 2, 3, 5),
max_shape=(3, 3, 3, 5),
),
]

Expand Down
10 changes: 6 additions & 4 deletions tests/py/dynamo/conversion/test_softplus_aten.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ def forward(self, x):

input_specs = [
Input(
shape=(-1, -1, -1),
dtype=torch.float32,
shape_ranges=[((1, 1, 1), (1, 2, 3), (3, 3, 3))],
min_shape=(1, 1, 1),
opt_shape=(1, 2, 3),
max_shape=(3, 3, 3),
),
]
self.run_test_with_dynamic_shape(TestModule(), input_specs)
Expand All @@ -36,9 +37,10 @@ def forward(self, x):

input_specs = [
Input(
shape=(-1, -1, -1, -1),
dtype=torch.float32,
shape_ranges=[((1, 1, 1, 5), (1, 2, 3, 5), (3, 3, 3, 5))],
min_shape=(1, 1, 1, 5),
opt_shape=(1, 2, 3, 5),
max_shape=(3, 3, 3, 5),
),
]

Expand Down
Loading