-
Notifications
You must be signed in to change notification settings - Fork 350
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
feat: dynamic shape support for pad ops #3045
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
posted minor comments - overall the changes LGTM
set_layer_name, | ||
) | ||
from torch_tensorrt.dynamo.conversion.impl.shape import get_shape_with_dynamic_shape | ||
from torch_tensorrt.fx.types import TRTTensor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you import from torch_tensorrt.dynamo
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your comment! I've updated the TRTTensor
to use torch_tensorrt.dynamo
as suggested.
new_dim_shape = impl.elementwise.add( | ||
ctx, target, source_ir, f"{name}_shape_dim_{i}", dim_shape, pad_sum | ||
) | ||
start_list[dim_index] = -pad_before |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious : Why are the values negative here and what is the expectation of TensorRT when you do layer.set_input(1, start_indices_tensor)
later ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The negative values in start_list[dim_index] = -pad_before
are used to indicate the starting point for the slicing operation in TensorRT's ISliceLayer
. When setting layer.set_input(1, start_indices_tensor)
, TensorRT interprets these negative start indices to appropriately offset the input tensor before applying padding.
Description
Added dynamic shape support for the following padding operations:
aten.constant_pad_nd
aten.reflection_pad1d
aten.reflection_pad2d
aten.reflection_pad3d
aten.replication_pad1d
aten.replication_pad2d
aten.replication_pad3d
aten._pad_circular
aten.pad
A commonly used function,
get_padded_shape_tensors
, has been introduced to adjust the dimensions of the input tensor to account for padding in various padding modes. This function simplifies the handling of dynamic shapes across different padding operations.Type of change
Checklist: