quant_pre_process SymbolicShapeInference
causes AttributeError: 'NoneType' object has no attribute 'HasField' when the model has a Constant node.
#22422
Labels
quantization
issues related to quantization
Describe the issue
When attempting to run
SymbolicShapeInference
on a model containing aConstant node
, an error occurs:AttributeError
: 'NoneType' object has no attribute 'HasField'.The issue arises from this part of the code in the symbolic_shape_infer.py file:
There are two key problems in this section:
Constant node
can have attributes other than just "value". For instance,Constant<value_float=1.0>()
would cause get_attribute to return None, which leads to the error.get_attribute
itself returns a value, we should be able to pass it directly toself.sympy_data_
without usingnumpy_helper.to_array(t)
, which triggers theAttributeError
.Suggested Solution:
The
_infer_Constant
sould handle different Constant attributes["sparse_value", "value", "value_float", "value_floats", "value_int", "value_ints", "value_string","value_strings"]
. Additionally, adjusting the code to bypass numpy_helper.to_array(t) when get_attribute returns a directly usable value could resolve the error.I can submit a pull request to address the issue. Please let me know if this is acceptable or if there are any specific guidelines I should follow.
To reproduce
You can reproduce it with the following code:
Urgency
No response
Platform
Linux
OS Version
Ubuntu 22.04.3 LTS
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: