Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

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

Ouverte
#23,812 2 commentaires 1 réaction 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
38/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
cpp, python
Domaine
backend

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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

Langage dominant
Python
Étoiles
5.1k
Forks
1.2k
Merge moyen
1 j 23 h
PR mergées (30 j)
713

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de pytorch/executorch

Toutes les issues de pytorch/executorch

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.