-
Notifications
You must be signed in to change notification settings - Fork 372
Description
Bug Description
When encountering a Conv1D operator in Dynamo, PyTorch can switch integer components, like dilation, into tuples. This is problematic for the Conv1D operator, since the extend_attr_to_tuple
used here, will not work:
TensorRT/py/torch_tensorrt/fx/converters/impl/convolution.py
Lines 111 to 115 in b3089bf
# Expand parameters manually for Conv1D computations | |
if is_conv1d: | |
padding = tuple(padding) + (0,) | |
stride = extend_attr_to_tuple(stride, 2) | |
dilation = extend_attr_to_tuple(dilation, 2) |
Specifically, the function extend_attr_to_tuple
, shown below, needs to be modified to do the following. It should be able to handle length-1 lists or tuples and extend those to the necessary length specified by the user.
TensorRT/py/torch_tensorrt/fx/converters/converter_utils.py
Lines 128 to 146 in b3089bf
def extend_attr_to_tuple( | |
val: Any, | |
num_elem: int, | |
) -> Tuple[Any, ...]: | |
""" | |
If `val` is not a tuple or a list, then we make a tuple of size `num_elem` by | |
replicating `val` `num_elem` times. | |
Args: | |
val (Any): Value that we want to process. | |
Returns: | |
A tuple. | |
""" | |
if not isinstance(val, (tuple, list)): | |
val = (val,) * num_elem | |
if isinstance(val, list): | |
val = tuple(val) | |
return val |
To Reproduce
Compile a model with a Conv1D operator using one of the Dynamo paths.
Expected behavior
Models with Conv1D operators should trace and compile successfully with AOT/Dynamo.
Environment
- Torch-TensorRT Version (e.g. 1.0.0): 8c62fca
- PyTorch Version (e.g. 1.0):
2.1.0.dev20230803+cu121