-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[QNN EP] Add remove_initializer_from_input in qnn.preprocess #25102
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
base: main
Are you sure you want to change the base?
[QNN EP] Add remove_initializer_from_input in qnn.preprocess #25102
Conversation
- Add argument "--exclude_initializer_from_input" to remove initializer from input if model.ir_version >= 4 - Add function argument on remove_initializer_from_input - Modify the onnxruntime_python.cmake to include remove_initializer_from_input.py
/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 successfully started running 5 pipeline(s). |
There was a problem hiding this 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 introduces a new option to exclude initializers from model inputs for ONNX models with ir_version >=4, addressing an issue related to initializers appearing as graph inputs.
- Adds a new argument "--exclude_initializer_from_input" across relevant scripts and the CMake build file.
- Refactors the remove_initializer_from_input function to accept a model argument and return a boolean indicating whether modifications were made.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
tools/python/remove_initializer_from_input.py | Refactored function to remove initializers from input and now returns a boolean flag; updated main block accordingly. |
onnxruntime/python/tools/quantization/execution_providers/qnn/preprocess.py | Integrated the exclude_initializer_from_input option into the QNN preprocessing logic. |
onnxruntime/python/tools/qnn/preprocess.py | Added new argument and documentation updates for excluding initializers from inputs. |
cmake/onnxruntime_python.cmake | Updated to include the new remove_initializer_from_input.py script in the build process. |
args = get_args() | ||
|
||
model = onnx.load(args.input) | ||
def remove_initializer_from_input(model: onnx.ModelProto) -> bool: | ||
if model.ir_version < 4: | ||
print("Model with ir_version below 4 requires to include initilizer in graph input") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a spelling error in the printed message: 'initilizer' should be corrected to 'initializer'.
print("Model with ir_version below 4 requires to include initilizer in graph input") | |
print("Model with ir_version below 4 requires to include initializer in graph input") |
Copilot uses AI. Check for mistakes.
Description
Motivation and Context
Initializer <name> appears in graph inputs and will not be treated as constant value/weight.
, we require the remove_initializer_from_input to be included inqnn.preprocess