Skip to content

[QNN EP] Add MaxRoiPool support via StridedSlice/ReduceMax/Concat decomposition - #542

Merged
qti-niscmami merged 10 commits into
mainfrom
dev/qti-niscmami/maxroipool-implementation
Aug 12, 2026
Merged

[QNN EP] Add MaxRoiPool support via StridedSlice/ReduceMax/Concat decomposition#542
qti-niscmami merged 10 commits into
mainfrom
dev/qti-niscmami/maxroipool-implementation

Conversation

@qti-niscmami

Copy link
Copy Markdown
Collaborator

Description

Adds QNN EP support for the ONNX MaxRoiPool operator. Because QNN has no MaxRoiPool/RoiPooling kernel that runs on the NPU, the op is decomposed into primitives that are supported on all backends (CPU, HTP, GPU): StridedSlice + ReduceMax per pooled bin, assembled with Concat/Reshape.

What it does

For each ROI, the adaptive bin geometry is computed at build time from the (constant) rois tensor, following the ONNX spec (hstart = y1 + floor(i·roi_h/ph), hend = y1 + ceil((i+1)·roi_h/ph), and likewise for width). Each bin becomes:

  • StridedSlice of the exact bin region from the NHWC feature map → ReduceMax over H,W (keepdims) → [1,1,1,C]
  • Empty/degenerate bins emit a static zero tensor (matching ONNX, which fills them with 0)

Per ROI the bin results are concatenated and reshaped to [1, ph, pw, C]; the per-ROI tiles are concatenated along the batch axis to form the [num_rois, ph, pw, C] output. The decomposition is exact for any constant ROI (handles overlapping / non-uniform bins and spatial_scale).

Constraints

  • rois must be a constant initializer (bin geometry is resolved at build time); a non-constant rois is rejected in IsOpSupported and falls back to the CPU EP.
  • An op-count guard (num_rois · pooled_h · pooled_w ≤ 4096) bounds graph size; larger configs fall back to the CPU EP.

…oipool-implementation

# Conflicts:
#	onnxruntime/core/providers/qnn/builder/opbuilder/qdq_constant_folding.cc
Comment thread onnxruntime/test/providers/qnn/maxroipool_test.cc
Comment thread onnxruntime/core/providers/qnn/builder/opbuilder/maxroipool_op_builder.cc Outdated
Comment thread onnxruntime/core/providers/qnn/builder/opbuilder/maxroipool_op_builder.cc Outdated
@qti-niscmami
qti-niscmami merged commit 1efd4c3 into main Aug 12, 2026
139 of 141 checks passed
@qti-niscmami
qti-niscmami deleted the dev/qti-niscmami/maxroipool-implementation branch August 12, 2026 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants