Skip to content

[QNN EP] Fix Clip op with min or max from QDQ#26601

Merged
adrianlizarraga merged 1 commit intomicrosoft:mainfrom
CodeLinaro:dev/yuduo/clip-qdq-minmax
Dec 19, 2025
Merged

[QNN EP] Fix Clip op with min or max from QDQ#26601
adrianlizarraga merged 1 commit intomicrosoft:mainfrom
CodeLinaro:dev/yuduo/clip-qdq-minmax

Conversation

@qti-yuduo
Copy link
Contributor

Motivation

QDQ node group selection logic currently navigate Clip op to UnaryNodeGroupSelector. This isn't properly handling the use case where Clip op has min/max provided from Q/DQ ops (still constant initializers).

image-2025-11-18-11-49-19-156

Changes:

  • Implement custom NodeGroupSelector so that Clip op is properly tagged for backend to consume.
  • Fix QNN EP Clip min/max parsing and perform de-quantize when needed.
  • Unit tests for both changes.

@quic-tirupath
Copy link
Contributor

@deval-patel and @chilo-ms
Could you please help to trigger CI pipeline for this PR

@quic-ashwshan
Copy link
Contributor

@chilo-ms - Could you please run CI and review/merge this change?

@edgchen1 edgchen1 added the ep:QNN issues related to QNN exeution provider label Dec 12, 2025
@yuslepukhin yuslepukhin requested a review from Copilot December 15, 2025 20:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an issue with QNN EP's handling of the Clip operator when min/max values are provided through Q/DQ nodes. Previously, Clip was incorrectly handled by the UnaryNodeGroupSelector, which couldn't properly recognize patterns where min/max inputs come from quantized sources.

Key changes:

  • Implemented a custom ClipNodeGroupSelector to properly handle Clip operations with 1-3 DQ inputs
  • Added dequantization logic in QNN EP's Clip op builder to convert quantized min/max values to floats
  • Fixed spelling error in function name (ExplictOpCheckExplicitOpCheck)

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
clip_op_test.cc Added three test cases validating Clip with quantized min-only, max-only, and min+max inputs
qdq_transformer_test.cc Added tests verifying ClipNodeGroupSelector properly identifies QDQ patterns for Clip operations
clip_op_builder.cc Added dequantization logic for quantized min/max inputs and fixed function name typo
utils.cc Removed Clip from unary ops map, created dedicated Clip ops map, and registered ClipNodeGroupSelector
qdq_selectors.h Declared ClipNodeGroupSelector class
qdq_selectors.cc Implemented ClipNodeGroupSelector::Check method to validate 1-3 DQ input patterns

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yuslepukhin
Copy link
Member

/azp run Linux QNN CI Pipeline, Win_TRT_Minimal_CUDA_Test_CI, Windows ARM64 QNN CI Pipeline, Windows GPU CUDA CI Pipeline, Windows GPU DML CI Pipeline, Windows GPU Doc Gen CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows OpenVINO CI Pipeline, Windows x64 QNN CI Pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@yuslepukhin
Copy link
Member

/asp run Windows GPU CUDA CI Pipeline, Windows GPU DML CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows OpenVINO CI Pipeline, Windows x64 QNN CI Pipeline

@yuslepukhin
Copy link
Member

Please, address or comment on the Copilot comments

@qti-yuduo
Copy link
Contributor Author

Please, address or comment on the Copilot comments

Done. But it's no harm to apply suggested change so lemme know if you feel strong about it.

@yuslepukhin
Copy link
Member

/azp run Linux QNN CI Pipeline, Win_TRT_Minimal_CUDA_Test_CI, Windows ARM64 QNN CI Pipeline, Windows GPU CUDA CI Pipeline, Windows GPU DML CI Pipeline, Windows GPU Doc Gen CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows OpenVINO CI Pipeline, Windows x64 QNN CI Pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@eserscor
Copy link
Contributor

/azp run "Linux QNN CI Pipeline", "Win_TRT_Minimal_CUDA_Test_CI", "Windows ARM64 QNN CI Pipeline", "Windows GPU CUDA CI Pipeline", "Windows GPU DML CI Pipeline", "Windows GPU Doc Gen CI Pipeline", "Windows GPU TensorRT CI Pipeline", "Windows OpenVINO CI Pipeline", "Windows x64 QNN CI Pipeline"

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@adrianlizarraga
Copy link
Contributor

Closing and reopening to get CI checks to run

@adrianlizarraga adrianlizarraga merged commit 9f95908 into microsoft:main Dec 19, 2025
89 checks passed
alex-spacemit pushed a commit to spacemit-com/onnxruntime that referenced this pull request Jan 20, 2026
## Motivation
QDQ node group selection logic currently navigate `Clip` op to
`UnaryNodeGroupSelector`. This isn't properly handling the use case
where `Clip` op has `min/max` provided from Q/DQ ops (still constant
initializers).

<img width="255" height="378" alt="image-2025-11-18-11-49-19-156"
src="https://github.com/user-attachments/assets/ec6250ee-68f3-40fa-8f60-93b1a400d5a0"
/>

## Changes:

- Implement custom NodeGroupSelector so that `Clip` op is properly
tagged for backend to consume.
- Fix QNN EP `Clip` min/max parsing and perform de-quantize when needed.
- Unit tests for both changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ep:QNN issues related to QNN exeution provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants