Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Cortex-M backend replaces channels-first dw conv with channels-last dw conv without handling the changed layout, fails at runtime

Abierto
#23,812 2 comentarios 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
38/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
cpp, python
Área
backend

Línea de trabajo

Start with the fake implementation quantized_depthwise_conv2d_meta in backends/cortex_m/ops/operators.py, which accepts channels-first input, and with the runtime check that raises 'input and output must be channels_last' in backends/cortex_m/ops/op_quantized_depthwise_conv2d.cpp. Run the attached test_depthwise_conv_layout.py repro to confirm the failure. Done means the pass either skips the replacement for channels-first input or inserts a layout conversion, and the repro runs without error.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug module: microcontrollers partner: arm
🐛 Describe the bug

A depthwise conv is replaced with a channels-last Cortex-M kernel without verifying that the input is channel-last. The fake implementation quantized_depthwise_conv2d_meta in backends/cortex_m/ops/operators.py happily takes a channels-first, computes output shape and returns a channel-last tensor. This doesn't work in the runtime kernel however, and the operator fails with

input and output must be channels_last

from backends/cortex_m/ops/op_quantized_depthwise_conv2d.cpp.

Two examples: one minimal, and one showing how this can show up naturally in a model.
(Note that the meandim example needs adding aten::mean.out and dim_order_ops::_to_dim_order_copy.out to the test runner, in backends/cortex_m/test/build_test_runner.sh)

class ChannelsFirstDepthwiseConv(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.conv = torch.nn.Conv2d(2, 2, 3, padding=1, groups=2, bias=False)

    def forward(self, x):
        return self.conv(x.contiguous())


class MeanPoolDepthwiseConv(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.conv = torch.nn.Conv2d(2, 2, 3, padding=1, groups=2, bias=False)

    def forward(self, x):
        # Average pooling over height naturally creates channels-first storage.
        x = x.mean(dim=2, keepdim=True)
        return self.conv(x)

as a test:

test_depthwise_conv_layout.py

Proposed fix:

  • Don't replace the operator that can't be handled
  • Or, add a layout conversion before it when replacing.

Additionally, it could be a good idea to check input layout in fake implementations if there are constraints on it.

Versions

Not relevant, this is a backend lowering issue in the executorch python code. Present on upstream 40d17e193e54b4d773e8da7a64a1e7a68a661e2e

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani @psiddh @AdrianLundell

Lenguaje dominante
Python
Estrellas
5.1k
Forks
1.2k
Merge medio
2 d 14 min
PR fusionados (30 d)
704

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de pytorch/executorch

Todos los issues de pytorch/executorch

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.