Skip to content

Conversation

@quic-tirupath
Copy link
Contributor

Description

  • Translate ONNX ScatterElements as QNN's ScatterElements Op
  • Handle unsupported reduction value i.e., "min"
  • Add unit tests to verify ScatterElements Op support on HTP

@edgchen1 edgchen1 added the ep:QNN issues related to QNN exeution provider label May 20, 2025
@HectorSVC
Copy link
Contributor

/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline,Windows x64 QNN CI Pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 5 pipeline(s).

@HectorSVC
Copy link
Contributor

Please check the doc to make sure there are no steps missing: https://onnxruntime.ai/docs/execution-providers/QNN-ExecutionProvider.html#add-new-operator-support-in-qnn-ep
For example, make sure the DQ->CumSum->Q is treat as a single node unit, so it's running as quantized CumSum instead of FP32 in FP16 mode on HTP. Another recent example is: #24659

@quic-tirupath quic-tirupath marked this pull request as draft June 5, 2025 18:35
 - Translate ONNX ScatterElements as QNN's ScatterElements Op
 - Handle unsupported reduction value i.e., "min"
 - Add unit tests to verify ScatterElements Op support on HTP
 - Add QDQ selector for ScatterElements to fold DQ and Q nodes on
   inputs and outputs of ScatterElements Op into a single nodeunit.
 - Add more unit tests to verify the ScatterElement Op translations
   in QNN EP
@quic-tirupath quic-tirupath force-pushed the dev/tirupath/qnn_scatterelements branch from 992764c to 16d2c32 Compare July 31, 2025 04:58
@quic-tirupath
Copy link
Contributor Author

Please check the doc to make sure there are no steps missing: https://onnxruntime.ai/docs/execution-providers/QNN-ExecutionProvider.html#add-new-operator-support-in-qnn-ep For example, make sure the DQ->CumSum->Q is treat as a single node unit, so it's running as quantized CumSum instead of FP32 in FP16 mode on HTP. Another recent example is: #24659

Thanks for pointing the missing functionality. The PR is updated with adding missing functionality.

@quic-tirupath quic-tirupath marked this pull request as ready for review July 31, 2025 05:20
@HectorSVC
Copy link
Contributor

/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline,Windows x64 QNN CI Pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 5 pipeline(s).

@HectorSVC HectorSVC requested a review from Copilot July 31, 2025 21:17
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 adds support for the ONNX ScatterElements operation to the QNN execution provider. It includes translation of the operator to QNN's ScatterElements op, handling of unsupported reduction modes (specifically "min"), and comprehensive test coverage.

Key changes:

  • Implements QNN EP support for ScatterElements with proper attribute handling (axis and reduction)
  • Adds validation to reject unsupported "min" reduction mode
  • Extends test infrastructure to support multi-type input operations and adds comprehensive unit tests

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/providers/qnn/simple_op_htp_test.cc Adds comprehensive test cases for ScatterElements on CPU and HTP backends
onnxruntime/test/providers/qnn/qnn_test_utils.h Extends test infrastructure with new template functions for multi-type input operations
onnxruntime/test/providers/cpu/tensor/scatter_op_test.cc Updates existing tests to exclude QNN EP for unsupported scenarios
onnxruntime/core/providers/qnn/builder/opbuilder/simple_op_builder.cc Implements ScatterElements operator translation with attribute processing
onnxruntime/core/providers/qnn/builder/opbuilder/base_op_builder.h Adds ONNX to QNN operator type mapping
onnxruntime/core/providers/qnn/builder/op_builder_factory.cc Registers ScatterElements operator builder
onnxruntime/core/optimizer/qdq_transformer/selectors_actions/shared/utils.cc Adds QDQ selector registration for ScatterElements
onnxruntime/core/optimizer/qdq_transformer/selectors_actions/qdq_selectors.h Declares ScatterElements QDQ selector class
onnxruntime/core/optimizer/qdq_transformer/selectors_actions/qdq_selectors.cc Implements ScatterElements QDQ validation logic
Comments suppressed due to low confidence (1)

onnxruntime/test/providers/qnn/simple_op_htp_test.cc:1363

  • Test name should follow consistent capitalization. Change 'int8' to 'Int8' to match the naming pattern used in other tests like 'ScatterElements_Int8_Reduction_Max'.
TEST_F(QnnHTPBackendTests, ScatterElements_int8_reduction_mul) {

@HectorSVC
Copy link
Contributor

Need to disable some Onnx node test: scatter_elements_with_negative_indices

@quic-tirupath
Copy link
Contributor Author

Need to disable some Onnx node test: scatter_elements_with_negative_indices

We are checking how can we disable it.
Adding below entry in file:onnx_backend_test_series.py is not helping.
"current_failing_tests_QNN": [ "^test_scatter_elements_with_negative_indices" ],

@quic-tirupath
Copy link
Contributor Author

Need to disable some Onnx node test: scatter_elements_with_negative_indices

We are checking how can we disable it. Adding below entry in file:onnx_backend_test_series.py is not helping. "current_failing_tests_QNN": [ "^test_scatter_elements_with_negative_indices" ],

@HectorSVC
this is fixed now. Could you please help to retrigger the CI job

@HectorSVC
Copy link
Contributor

/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline,Windows x64 QNN CI Pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 5 pipeline(s).

@HectorSVC HectorSVC merged commit f755b8a into microsoft:main Aug 1, 2025
86 of 87 checks passed
@quic-tirupath quic-tirupath deleted the dev/tirupath/qnn_scatterelements branch August 1, 2025 16:40
sanketkaleoss pushed a commit to sanketkaleoss/onnxruntime that referenced this pull request Aug 11, 2025
### Description
 - Translate ONNX ScatterElements as QNN's ScatterElements Op
 - Handle unsupported reduction value i.e., "min"
 - Add unit tests to verify ScatterElements Op support on HTP

---------

Co-authored-by: Tirupathi Reddy T <[email protected]>
gedoensmax pushed a commit to gedoensmax/onnxruntime that referenced this pull request Sep 2, 2025
### Description
 - Translate ONNX ScatterElements as QNN's ScatterElements Op
 - Handle unsupported reduction value i.e., "min"
 - Add unit tests to verify ScatterElements Op support on HTP

---------

Co-authored-by: Tirupathi Reddy T <[email protected]>
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.

4 participants