Skip to content

[QNN-EP] Fix the input order in gen_qnn_ctx_onn_model.py #25090

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

chuteng-quic
Copy link
Contributor

Description

In the original script, the order of inputs in the generated ONNX model follows the order in the JSON file instead of the id.
Therefore, the script will first sort the inputs by ID before wrapping the context into the new model.

Motivation and Context

If we use gen_qnn_ctx_onnx_model.py, it will wrap the context based on the order in qnn_model_net.json instead of the id in qnn_model_net.json, which may result in the onnx model having an incorrect order of inputs.

@chuteng-quic chuteng-quic changed the title Fix the input order in gen_qnn_ctx_onn_model.py [QNN-EP] Fix the input order in gen_qnn_ctx_onn_model.py Jun 17, 2025
@HectorSVC HectorSVC requested a review from Copilot June 19, 2025 03:40
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

This PR addresses the incorrect ordering of inputs in the generated ONNX model by sorting tensor entries by their id rather than relying on the JSON file order. Key changes include updating the constructor of QnnTensorStruct to accept additional parameters (including id), enforcing key presence in the JSON parsing logic, and sorting both input and output tensors by their id.

@HectorSVC HectorSVC added the ep:QNN issues related to QNN exeution provider label Jun 19, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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