Skip to content

Commit dd3b096

Browse files
[executorch] Arm backend: Preserve Arm pass behavior for Conv1d conversion (pytorch#22086)
Keep the shared Conv1d-to-Conv2d transform on the Arm pass hierarchy so whole-graph retracing retains Arm handling for quantized operators without fake kernels. Restore targeted-pass filtering for convolution graphs. Add a quantized Conv1d-plus-LeakyReLU regression that exercises the failure reported on D116841181. Test plan: - `buck test @fbcode//mode/dev-nosan fbcode//executorch/backends/arm/test:conv1d -- --exact "fbcode//executorch/backends/arm/test:conv1d - test_conv1d.py::test_convolution_1d_with_leaky_relu_tosa_INT"` - `arc lint -a` and `arc lint` on changed files - Attempted the exact `test_ceres_u55_handwriting` CI repro; the Buck daemon was killed by host OOM before completion. - `python -m py_compile backends/arm/_passes/conv1d_unsqueeze_pass.py backends/arm/test/ops/test_conv1d.py` This PR was authored with Codex. cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani
1 parent ff679f5 commit dd3b096

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎backends/arm/_passes/conv1d_unsqueeze_pass.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from typing import Set, Type
99

10+
from executorch.backends.arm._passes import ArmOpTargetedPass
1011
from executorch.backends.arm._passes.convert_squeezes_to_view import (
1112
ConvertSqueezesToViewPass,
1213
)
@@ -15,14 +16,16 @@
1516
from executorch.backends.transforms.convert_conv1d_to_conv2d_pass import (
1617
ConvertConv1dToConv2dPass,
1718
)
19+
from executorch.exir.dialects._ops import ops as exir_ops
1820
from executorch.exir.pass_base import ExportPass
1921

2022

21-
class Conv1dUnsqueezePass(ConvertConv1dToConv2dPass):
23+
class Conv1dUnsqueezePass(ConvertConv1dToConv2dPass, ArmOpTargetedPass):
2224
"""Arm wrapper for the shared Conv1d-to-Conv2d transform."""
2325

2426
_passes_required_after: Set[Type[ExportPass]] = {
2527
ConvertSqueezesToViewPass,
2628
RewriteConvPass,
2729
SizeAdjustInputPass,
2830
}
31+
target_ops = (exir_ops.edge.aten.convolution.default,)

‎backends/arm/test/ops/test_conv1d.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ def forward(self, x):
118118
return x
119119

120120

121+
class Conv1dWithLeakyReLU(Conv1d):
122+
def forward(self, x):
123+
return torch.nn.functional.leaky_relu(super().forward(x), negative_slope=0.0)
124+
125+
121126
conv1d_2_3x2x40_nobias = Conv1d(
122127
in_channels=2,
123128
out_channels=3,
@@ -327,6 +332,18 @@ def test_convolution_1d_tosa_INT(test_data):
327332
pipeline.run()
328333

329334

335+
def test_convolution_1d_with_leaky_relu_tosa_INT():
336+
model = Conv1dWithLeakyReLU()
337+
pipeline = TosaPipelineINT[input_t](
338+
model,
339+
model.get_inputs(),
340+
[aten_op, "torch.ops.aten.leaky_relu.default"],
341+
[exir_op, "executorch_exir_dialects_edge__ops_aten_leaky_relu_default"],
342+
qtol=1,
343+
)
344+
pipeline.run()
345+
346+
330347
@common.parametrize("test_data", test_data_INT)
331348
@common.XfailIfNoCorstone300
332349
def test_convolution_1d_u55_INT(test_data):

0 commit comments

Comments
 (0)