Skip to content

Arm backend: support depthwise Conv3D#19902

Open
vacu9708 wants to merge 1 commit into
pytorch:mainfrom
vacu9708:depthwise_conv3d
Open

Arm backend: support depthwise Conv3D#19902
vacu9708 wants to merge 1 commit into
pytorch:mainfrom
vacu9708:depthwise_conv3d

Conversation

@vacu9708
Copy link
Copy Markdown
Contributor

@vacu9708 vacu9708 commented May 30, 2026

Summary

Depthwise Conv3D (in_channels == groups, rank-5 input) previously crashed with a RuntimeError inside RewriteConvPass because TOSA has no DEPTHWISE_CONV3D op. DecomposeGroupedConvPass already handles non-depthwise grouped Conv3D by splitting it into groups==1 convolutions via slice→conv→cat, but it explicitly skipped the depthwise case since Conv2D depthwise maps to the native DEPTHWISE_CONV2D TOSA op.

For Conv3D there is no such native op, so the fix is to extend DecomposeGroupedConvPass to stop skipping depthwise when the input is rank 5(Conv3D).
The existing slice→CONV3D→cat decomposition can handle it correctly.

flowchart LR
    DW2D["Depthwise Conv2D\n(in_channels == groups, rank 4)"]
    DW3D["Depthwise Conv3D\n(in_channels == groups, rank 5)"]
    GRP["DecomposeGroupedConvPass"]
    RC2D["RewriteConvPass"]
    RC3D["RewriteConvPass"]
    DELEGATE_CONV2D["DEPTHWISE_CONV2D"]
    DELEGATE_CONV3D["CONV3D"]

    DW2D --> RC2D
    DW3D -->|"decomposed"| GRP
    GRP -->|"CONV3D (groups==1)"| RC3D
    RC2D -->|"delegated to native op"| DELEGATE_CONV2D
    RC3D -->|"delegated to native op"| DELEGATE_CONV3D

Loading

Files changed:

File Change
backends/arm/_passes/decompose_grouped_conv_pass.py In call_operator, narrow the depthwise skip to Conv2D only (len(input.data.shape) != 5); for rank-5 inputs(Conv3D) fall through to the existing decomposition.
backends/arm/_passes/rewrite_conv_pass.py Update comment in _is_conv3d to reflect that both grouped and depthwise Conv3D are now decomposed upstream; retain the RuntimeError as defense-in-depth.
backends/arm/test/ops/test_conv3d.py Rewrite test_convolution_3d_tosa_FP_depthwise to assert delegation

Test result

python -m pytest backends/arm/test/ops/test_conv3d.py::test_convolution_u55_INT_not_delegated_3d
# 2 passed, 0 failed.
lintrunner -a \
    backends/arm/_passes/decompose_grouped_conv_pass.py \
    backends/arm/_passes/rewrite_conv_pass.py \
    backends/arm/test/ops/test_conv3d.py
# ok No lint issues.

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

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 30, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19902

Note: Links to docs will display an error until the docs builds have been completed.

⚠️ 11 Awaiting Approval

As of commit 5e0aff3 with merge base acce7cd (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 30, 2026
@github-actions github-actions Bot added ciflow/trunk module: arm Issues related to arm backend labels May 30, 2026
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 30, 2026

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/trunk

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

@github-actions
Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

DecomposeGroupedConvPass skips depthwise convolutions (in_channels ==
groups) because Conv2D depthwise maps to TOSA DEPTHWISE_CONV2D. For
Conv3D (rank-5 input) there is no DEPTHWISE_CONV3D op, so the skip
caused RewriteConvPass to raise a RuntimeError during preprocess.

Narrow the depthwise skip to Conv2D only. For rank-5 inputs the pass
falls through to the existing slice->CONV3D->cat decomposition, which
already handles arbitrary groups and produces the correct per-channel
computations that depthwise convolution requires.

Signed-off-by: Youngsik Yang <vacu9708@gmail.com>
@vacu9708 vacu9708 force-pushed the depthwise_conv3d branch from b94b5b8 to 5e0aff3 Compare May 30, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: arm Issues related to arm backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants