[MLAS] Update the NHWC sans transposes path to also support Depthwise convolutions#28565
Conversation
* Allow for NHWC Depthwise convolutions when groups are values other than 1 * Added verification tests * Changed the fallback / skip tests to now check for asymettric padding, non-depthwise grouped conv, and multiplier > 1 Signed-off-by: Orlaith Monahan <orlaith.monahan@arm.com>
Signed-off-by: Orlaith Monahan <orlaith.monahan@arm.com>
|
@microsoft-github-policy-service agree company="Arm" |
There was a problem hiding this comment.
Pull request overview
Expands the existing MLAS/KleidiAI NHWC “no-transpose” convolution fast path to support true depthwise convolutions (grouped conv where filters-per-group == 1), and wires that capability through the NHWC transformer plus adds test/benchmark coverage.
Changes:
- Relax MLAS NHWC capability gating to allow GroupCount > 1 only for true depthwise (FilterCount-per-group == 1).
- Update NHWC transformer filtering to pass the real group count and compute per-group filter count.
- Extend KleidiAI NHWC execution to handle grouped NHWC tensors via per-group gather/compute/scatter, plus add unit tests and a benchmark comparison.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| onnxruntime/core/mlas/lib/convolve.cpp | Updates NHWC capability gate to allow depthwise grouped convs. |
| onnxruntime/core/mlas/lib/kleidiai/convolve_kleidiai.cpp | Implements grouped-NHWC handling by gathering/scattering channels per group. |
| onnxruntime/core/optimizer/nhwc_transformer.cc | Passes group count + per-group filter count into the NHWC fast-path capability check. |
| onnxruntime/core/providers/cpu/nn/conv.h | Broadens KleidiAI fast-path compilation guard to MLAS_TARGET_ARM64. |
| onnxruntime/core/providers/cpu/nn/conv.cc | Same guard update for KleidiAI fast-path code. |
| onnxruntime/test/optimizer/nhwc_transformer_test.cc | Adds/updates tests validating depthwise enablement and expected skip cases. |
| onnxruntime/test/contrib_ops/fused_conv_test.cc | Adds an NHWC depthwise FusedConv correctness test (conditionally enabled). |
| onnxruntime/test/mlas/bench/bench_sconv.cpp | Adds benchmark cases comparing NCHW baseline vs NHWC KleidiAI fast path, including depthwise shapes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Orlaith Monahan <orlaith.monahan@arm.com>
…eSme and only size it once * Fixed some grammer in throw statements Signed-off-by: Orlaith Monahan <orlaith.monahan@arm.com>
Review of PR #28565 — [MLAS] Update the NHWC sans transposes path to also support Depthwise convolutionsOverall direction is good — extending the existing NHWC no-transpose KleidiAI/SME path to depthwise is worthwhile, and the gate relaxation in Likely bugs / correctness
Performance
Style / hygiene
Things that look good
SummaryRequired before merge:
Strongly recommended:
Nice-to-have / nits:
|
* Update the capabilites for when grouped is supported and adapt the execution path correctly * Added filter validation for the Depthwise branch * Added a regression test for PreActivation Signed-off-by: Orlaith Monahan <orlaith.monahan@arm.com>
Signed-off-by: Orlaith Monahan <orlaith.monahan@arm.com>
Signed-off-by: Orlaith Monahan <orlaith.monahan@arm.com>
|
Sorry, for the delay. Some of the refactors caused test errors on our CI. Should all be good now. :) |
Re-review of PR #28565 — second passVerdict: Approve (pending green CI on the most-recent merge from main). Every required item from the prior review is addressed, the new commits read cleanly, and the previously-broken activation path is now exercised by a regression test. Items from the prior review — statusRequired-before-merge
Strongly recommended
Nice-to-have
Not addressed (cosmetic only — no objection)
New thing worth a sanity-checkThe new The Bottom lineSolid follow-up. The activation correctness bug is gone, the gate is tightened to match what the kernel actually handles, the kernel-floor and filter-count contracts are explicit, and the cleanups landed. Once the most-recent merge-from-main commit ( |
|
Cheers Hari, |
Oh I will just squash and merge. Don't worry - that comment was from my automated review tool :) Thanks for this PR ! |
Description
A path for MLAS to support NHWC Convolutions without the need for transposes was added in PR: #26834
This PR expands those changes to also support Depthwise Convolutions via the same pathway
What changed:
1.
depthwise Conv/FusedConv nodes get rewritten to com.microsoft.NhwcFusedConv.
onnxruntime/test/optimizer/nhwc_transformer_test.cc:416.
Added performance benchmark tests to allow for comparison between the new NHWC path and the old NCHW default.
Sample output: