Skip to content

[QNN EP] Fix segfault in PadNodeGroupSelector when dq_nodes is empty (#28717)#29220

Closed
yuslepukhin wants to merge 2 commits into
mainfrom
yuslepukhin/gh_issue_28717_qnn_mobile
Closed

[QNN EP] Fix segfault in PadNodeGroupSelector when dq_nodes is empty (#28717)#29220
yuslepukhin wants to merge 2 commits into
mainfrom
yuslepukhin/gh_issue_28717_qnn_mobile

Conversation

@yuslepukhin

Copy link
Copy Markdown
Member

This pull request improves the robustness of the QDQ transformer by correcting the logic in the PadNodeGroupSelector and 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 input validation: Updated the input validation logic in PadNodeGroupSelector::Check (in qdq_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.
  • Regression test for no DQ inputs: Added a new test (QDQ_Selector_Test_Pad_NoDQInputs_ReturnsNullopt) in qdq_transformer_test.cc to verify that the selector returns nullopt when 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.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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::Check validation to require 1 or 2 DQ inputs (rejects 0 and >2).
  • Added a unit test that builds a float -> Pad -> Q graph (no DQ inputs to Pad) and verifies the selector returns nullopt.

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.

@yuslepukhin yuslepukhin changed the title Fix segfault in PadNodeGroupSelector when dq_nodes is empty (#28717) [QNN EP] Fix segfault in PadNodeGroupSelector when dq_nodes is empty (#28717) Jun 22, 2026
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.

[Mobile] QNN EP yields Segmentation Fault on PadNodeGroupSelector Check if dq_nodes are empty

2 participants