[MLAS][KleidiAI] Integrate Depthwise 3x3 Conv Kernel#29441
[MLAS][KleidiAI] Integrate Depthwise 3x3 Conv Kernel#29441JonathanC-ARM wants to merge 1 commit into
Conversation
Signed-off-by: Jonathan Clohessy <Jonathan.Clohessy@arm.com>
There was a problem hiding this comment.
Pull request overview
This PR integrates an Arm® KleidiAI™ SME2-backed FP32 depthwise 3x3 convolution path into MLAS, wires it into the existing KleidiAI CPU convolution routing (Depthwise → IGemm → SGemmFallback → NoKleidiAi), and enables NHWC graph transformation when the new depthwise channels-last capability is available. It also adds an MLAS unit test to validate both the direct KleidiAI depthwise entrypoint and end-to-end routing through MlasConv in channels-last mode.
Changes:
- Added a new KleidiAI FP32 depthwise convolution implementation and ukernel selection plumbing.
- Integrated a new
ConvRoute::Depthwiseinto KleidiAI conv prepare/dispatch and enabled NHWC transform gating for supported depthwise shapes. - Added MLAS unit tests covering direct depthwise invocation and
MlasConvchannels-last routing.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| onnxruntime/test/mlas/unittest/test_dwconv_kleidiai.cpp | Adds unit tests for KleidiAI depthwise conv (direct call and MlasConv NHWC path). |
| onnxruntime/core/optimizer/nhwc_transformer.cc | Extends NHWC transform filtering to consider depthwise channels-last support constraints. |
| onnxruntime/core/mlas/lib/kleidiai/mlasi_kleidiai.h | Adds depthwise support/entrypoint declarations and introduces ConvRoute::Depthwise selection. |
| onnxruntime/core/mlas/lib/kleidiai/dw_conv_kleidiai.cpp | Implements the FP32 depthwise 3x3 kernel path, including layout conversions and packing. |
| onnxruntime/core/mlas/lib/kleidiai/convolve_kleidiai.cpp | Wires depthwise routing into KleidiAI conv prepare/dispatch and refactors IGEMM capability checks. |
| onnxruntime/core/mlas/lib/kai_ukernel_interface.h | Generalizes the ukernel wrapper type and adds a depthwise ukernel wrapper typedef and accessor. |
| onnxruntime/core/mlas/lib/kai_ukernel_interface.cpp | Registers the SME2 depthwise ukernel and exposes it via GetKleidiAIDepthwiseConvUKernel(). |
| onnxruntime/core/mlas/lib/convolve.cpp | Enables MlasConvSupportsDepthwiseChannelsLast2DFloatKernel for KleidiAI-supported shapes to unlock NHWC transforms. |
| cmake/onnxruntime_mlas.cmake | Adds the new depthwise source file to the KleidiAI MLAS build. |
| if (!UseSME2 || feature_map == nullptr || weights == nullptr || out == nullptr) { | ||
| return false; | ||
| } | ||
|
|
||
| if (batches != 1 || channels == 0) { | ||
| return false; | ||
| } |
Review —
|
Description
This PR adds a Arm® KleidiAI™ backed f32 depthwise convolution path in MLAS and wires it into the CPU/KleidiAI convolution routing flow.
The new path targets eligible depthwise convolutions using the KleidiAI SME2 depthwise ukernel. It is integrated as a first-class KleidiAI convolution route so depthwise dispatch is handled consistently with the existing IGEMM / SGEMM fallback routing.
Changes
onnxruntime/core/mlas/lib/kleidiai/dw_conv_kleidiai.cppConvRoute::Depthwise.DepthwiseIGemmSGemmFallbackNoKleidiAiSupported depthwise shape envelope
The current KleidiAI depthwise route supports f32 depthwise convolution with:
3x3kernelThe implementation handles NHWC directly and can fall back to internal NCHW to NHWC conversion when needed.
Example Performance Results
mobilenet_v1_f32.onnxmobilenetv1_ssd_f32.onnxretinaface_f32.onnxdeeplabv3_mobilenetv2_f32.onnxde_efficientnetlitev3_f32.onnx