Skip to content

🐛 [Bug] aten.convolution fails when 1D stride is tuple #2185

Closed
@gs-olive

Description

@gs-olive

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:

# 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.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcomponent: convertersIssues re: Specific op converters

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions