馃悰 Describe the bug
When trying to lower a Conv2d operator with a single-element stride array, the Conv1dUsqueezePass errors out. This is because it is using stride to determine if a convolution is 1d (there is a single core op for all convs). From a quick look at the op set, it looks like we should maybe use weight rank instead.
In the conv2d node visitor logic, it also assumes that stride/dilation/etc. have length equal to the conv dimension, which isn't always the case. Using the repro below and adding dilation=[2] to the Conv2d module will cause lowering to fail in the node visitor.
Repro:
import torch
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner
from executorch.exir import to_edge_transform_and_lower
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
self.conv = torch.nn.Conv2d(3, 3, 5, [2])
def forward(self, x):
return self.conv(x)
inputs = (
torch.randn(1, 3, 16, 16),
)
ep = torch.export.export(Model(), inputs)
et_program = to_edge_transform_and_lower(
ep,
partitioner=[XnnpackPartitioner()]
).to_executorch()
Output:
File ~/miniconda3/envs/pytorch/lib/python3.11/site-packages/executorch/backends/xnnpack/_passes/conv1d_unsqueeze_pass.py:191, in Conv1dUnsqueezePass.call(self, graph_module)
189 # Since we are overriding "call", we need to call the parent's "call"
190 # to retrace the graph and regenerate metadata
--> 191 graph_module = super().call(graph_module).graph_module
193 return PassResult(graph_module, True)
...
File ~/miniconda3/envs/pytorch/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py:762, in conv(fake_mode, func, *args, **kwargs)
761 if func is aten.convolution.default:
--> 762 conv_backend = torch._C._select_conv_backend(**kwargs)
763 else:
RuntimeError: expected stride to be a single integer value or a list of 3 values to match the convolution dimensions, but got stride=[2, 1]
...
Exception: An error occurred when running the 'Conv1dUnsqueezePass' pass after the following passes: []
Versions
N/A
cc @digantdesai @mcr229 @cbilgin
馃悰 Describe the bug
When trying to lower a Conv2d operator with a single-element stride array, the Conv1dUsqueezePass errors out. This is because it is using stride to determine if a convolution is 1d (there is a single core op for all convs). From a quick look at the op set, it looks like we should maybe use weight rank instead.
In the conv2d node visitor logic, it also assumes that stride/dilation/etc. have length equal to the conv dimension, which isn't always the case. Using the repro below and adding dilation=[2] to the Conv2d module will cause lowering to fail in the node visitor.
Repro:
Output:
Versions
N/A
cc @digantdesai @mcr229 @cbilgin