Skip to content

[QNN EP] Add QNN EP UDO support #25076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

chenweng-quic
Copy link
Contributor

@chenweng-quic chenweng-quic commented Jun 16, 2025

Description

Add UDO support in QNN

Example usage:
./onnx_test_runner -v -e qnn -j 1 -i "backend_path|./libQnnCpu.so op_packages|<op_type>:<op_package_path>:<interface_symbol_name>[:<target>],<op_type2>:<op_package_path2>:<interface_symbol_nam2e>[:<target2>]" <models>

Motivation and Context

Add QNN EP UDO support.
For more information, ref op packages

@HectorSVC HectorSVC added the ep:QNN issues related to QNN exeution provider label Jun 16, 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

Copy link

Azure Pipelines successfully started running 5 pipeline(s).

@HectorSVC HectorSVC requested a review from Copilot June 16, 2025 16:35
Copy link
Contributor

@Copilot 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

Adds support for loading and registering user-defined op packages (UDO) in the QNN execution provider via a new op_packages configuration option.

  • Extended test runners and CLI tools to parse and validate an op_packages argument.
  • Implemented ParseOpPackages, integrated it into QNNExecutionProvider and QnnBackendManager, and invoked a new LoadOpPackage() step.
  • Introduced UDOBuilder and updated the builder factory to register custom UDO-based operators.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
onnxruntime/test/perftest/ort_test_session.cc Added op_packages to the session config keys and validated its value.
onnxruntime/test/perftest/command_args_parser.cc Updated help text to document the op_packages CLI option.
onnxruntime/test/onnx/main.cc Enhanced usage output to include op_packages description.
onnxruntime/core/providers/qnn/qnn_execution_provider.cc Added ParseOpPackages helper and integrated it into provider initialization.
onnxruntime/core/providers/qnn/builder/qnn_utils.cc Clarified printing of 64-bit scalar types to note UDO support.
onnxruntime/core/providers/qnn/builder/qnn_backend_manager.h Extended QnnBackendManagerConfig and manager class to store op_packages.
onnxruntime/core/providers/qnn/builder/qnn_backend_manager.cc Implemented LoadOpPackage() logic and invoked it in SetupBackend().
onnxruntime/core/providers/qnn/builder/opbuilder/udo_builder.cc Added UDOBuilder for UDO operator construction.
onnxruntime/core/providers/qnn/builder/opbuilder/base_op_builder.h Enabled scalar handling for int64_t (64-bit) types for UDO.
onnxruntime/core/providers/qnn/builder/op_builder_factory.h Introduced APIs to register UDO builders in the factory.
onnxruntime/core/providers/qnn/builder/op_builder_factory.cc Registered the global OpBuilderRegistrations instance for UDO.
Comments suppressed due to low confidence (3)

onnxruntime/core/providers/qnn/builder/qnn_backend_manager.cc:324

  • Missing #include at the top of the file; std::filesystem::path requires the header.
std::filesystem::path op_package_path = op_package[1];

onnxruntime/core/providers/qnn/builder/qnn_backend_manager.cc:382

  • Typo in variable name 'op_package_for_registeration' and related log messages; should be 'op_package_for_registration'.
std::string op_package_for_registeration = op_package_path.stem().string();

onnxruntime/core/providers/qnn/qnn_execution_provider.cc:182

  • No unit tests currently cover ParseOpPackages; adding tests for valid and invalid package strings would help prevent regressions.
static void ParseOpPackages(const std::string& op_packages_string, std::vector<std::vector<std::string>>& op_packages) {

@HectorSVC
Copy link
Contributor

Need to add new provider options "op_packages" here:

Please also list all the valid value for target.

Also need to update the doc under gh-pages branch once the PR get merged:
https://github.com/microsoft/onnxruntime/blob/gh-pages/docs/execution-providers/QNN-ExecutionProvider.md

@chenweng-quic
Copy link
Contributor Author

chenweng-quic commented Jun 17, 2025

Need to add new provider options "op_packages" here:

Please also list all the valid value for target.

done

Also need to update the doc under gh-pages branch once the PR get merged: https://github.com/microsoft/onnxruntime/blob/gh-pages/docs/execution-providers/QNN-ExecutionProvider.md

This might need discussion since on Windows it has signing issue, and most of users may not be able to use this feature.

@chenweng-quic chenweng-quic requested a review from HectorSVC June 18, 2025 01:34
@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

Copy link

Azure Pipelines successfully started running 5 pipeline(s).

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.

2 participants