Error when quantizing model #13451
Answered
by
yufenglee
wangjia184
asked this question in
General
-
I am encountering the following error when quantizing a model converted from tensorflow File "/opt/homebrew/lib/python3.10/site-packages/onnxruntime/quantization/quantize.py", line 188, in quantize_static
quantizer.quantize_model()
File "/opt/homebrew/lib/python3.10/site-packages/onnxruntime/quantization/qdq_quantizer.py", line 157, in quantize_model
op_quantizer.quantize()
File "/opt/homebrew/lib/python3.10/site-packages/onnxruntime/quantization/operators/activation.py", line 106, in quantize
if not self.quantizer.is_activation_symmetric and self.quantizer.try_replacing_upstream_output(
File "/opt/homebrew/lib/python3.10/site-packages/onnxruntime/quantization/qdq_quantizer.py", line 184, in try_replacing_upstream_output
self.tensors_to_quantize.remove(upstream_output_name)
ValueError: list.remove(x): x not in list The model is firstly converted from TF2.0 Keras model into ONNX model successfully. But then def convert_to_onnx_model(file_name):
spec = (tf.TensorSpec((1, 4, 15, 15), tf.float32, name="input"),)
tf2onnx.convert.from_keras( mymodel, input_signature=spec, opset=17, output_path=file_name+".2")
dr = SampleInputDataReader()
quantize_static(
file_name+".2",
file_name,
dr,
quant_format=QuantFormat.QDQ,
per_channel=False,
activation_type=QuantType.QInt8,
weight_type=QuantType.QInt8,
optimize_model=False,
) It failed at this line Further information
Here is the ONNX model converted from tensorflow model, you can check it in tools like Netron Model opset: 17 Does anyone have an idea why it failed? |
Beta Was this translation helpful? Give feedback.
Answered by
yufenglee
Oct 26, 2022
Replies: 1 comment
-
It should be same issue as #12556. Could you please upgrade to 1.13.1 and have a try? |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
wangjia184
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It should be same issue as #12556. Could you please upgrade to 1.13.1 and have a try?