[QNN EP] Fix segfault in PadNodeGroupSelector when dq_nodes is empty (#28717)#29220
Closed
yuslepukhin wants to merge 2 commits into
Closed
[QNN EP] Fix segfault in PadNodeGroupSelector when dq_nodes is empty (#28717)#29220yuslepukhin wants to merge 2 commits into
yuslepukhin wants to merge 2 commits into
Conversation
PadNodeGroupSelector::Check only rejected num_dq_inputs > 2, allowing an empty dq_nodes vector to pass through. The subsequent access to dq_nodes[0] caused a segmentation fault on QNN EP with certain quantized models (e.g., Conv TasNet). Fix: reject num_dq_inputs < 1 in addition to > 2, enforcing the documented requirement of 1 or 2 DQ inputs for Pad. Add regression test that verifies the selector returns nullopt when a Pad node has no DQ inputs.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a crash in the QDQ transformer’s PadNodeGroupSelector by ensuring the selector rejects Pad nodes that have no DequantizeLinear (DQ) inputs, and adds a regression test to lock in the behavior (issue #28717).
Changes:
- Tightened
PadNodeGroupSelector::Checkvalidation to require 1 or 2 DQ inputs (rejects 0 and >2). - Added a unit test that builds a
float -> Pad -> Qgraph (no DQ inputs to Pad) and verifies the selector returnsnullopt.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| onnxruntime/core/optimizer/qdq_transformer/selectors_actions/qdq_selectors.cc | Prevents invalid selection by rejecting Pad nodes when dq_nodes is empty (avoids out-of-bounds access). |
| onnxruntime/test/optimizer/qdq_transformer_test.cc | Adds regression coverage for the “Pad with no DQ inputs” case to ensure the selector returns nullopt and does not crash. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the robustness of the QDQ transformer by correcting the logic in the
PadNodeGroupSelectorand adding a regression test to ensure correct behavior when there are no Dequantize (DQ) inputs to a Pad node. The main focus is to prevent invalid node selection in quantization scenarios.Bug fix and test addition:
PadNodeGroupSelector::Check(inqdq_selectors.cc) to correctly reject Pad nodes that have fewer than one or more than two DQ inputs, ensuring the selector cannot be erroneously applied to nodes without DQ inputs.QDQ_Selector_Test_Pad_NoDQInputs_ReturnsNullopt) inqdq_transformer_test.ccto verify that the selector returnsnulloptwhen the Pad node has no DQ inputs, preventing incorrect quantization transformations and guarding against regressions related to issue [Mobile] QNN EP yields Segmentation Fault on PadNodeGroupSelector Check if dq_nodes are empty #28717.