-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Issue with performing shape inference using symbolic_shape_infer.py with Phi-3 ONNX Models #21194
Comments
@kunal-vaishnavi, could you take a look at symbolic shape inference works on phi-3 models. |
The uploaded Phi-3 ONNX models already have been symbolic shape inferenced with dynamic axes. The symbolic shape inference for most quantization operators is defined in each operator's spec. onnxruntime/onnxruntime/core/graph/contrib_ops/contrib_defs.cc Lines 3434 to 3481 in 6baaaf5
Here is the list of supported operators whose shapes can be symbolically inferred in the onnxruntime/onnxruntime/python/tools/symbolic_shape_infer.py Lines 127 to 247 in 6baaaf5
|
@kunal-vaishnavi, thanks for the response. I have a few questions and comments from my side:
From my understanding, this is how Netron visualizes shape inferenced operators after running the model through the
|
You can find the shape inference by clicking on the operator and pressing the '+' icon next to the right of each input name and output name. Here is an example.
Yes, your error occurs because symbolic shape inference for
The uploaded Phi-3 ONNX models are created via ONNX Runtime GenAI's model builder. The shape inferences for their operators are created here in the model builder using |
### Description Support MatMulNBits shape infer in SymbolicShapeInference MatMulNBits's B input is rank-2, so implicit merge does not apply. ### Motivation and Context [Issue with performing shape inference using symbolic_shape_infer.py with Phi-3 ONNX Models · Issue #21194 · microsoft/onnxruntime (github.com)](#21194)
Describe the issue
I am running into this error when I run
SymbolicShapeInference.infer_shapes()
function on Phi 3 mini onnx model optimized for CPU. From my understanding, looks likeinfer_shapes()
is not able to infer shape forMatMulNBits
op (https://github.com/microsoft/onnxruntime/blob/rel-1.18.0/docs/ContribOperators.md#com.microsoft.MatMulNBits)This issue might not be limited to Phi-3. I suspect this has to do with the operator domain. Does the
infer_shapes()
automatically work on operators fromcom.microsoft
domain?I made the input and output dims of the onnx model static before performing shape inference using
update_inputs_outputs_dims()
from https://github.com/onnx/onnx/blob/main/onnx/tools/update_model_dims.pyError:
To reproduce
Download Model:
Packages:
Code:
Urgency
No response
Platform
Windows
OS Version
11
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
1.18.0
ONNX Runtime API
Python
Architecture
X64
Execution Provider
Default CPU
Execution Provider Library Version
No response
The text was updated successfully, but these errors were encountered: