onnxruntime: NOT_IMPLEMENTED : Could not find an implementation for ConvInteger(10) node with name 'Conv_0_quant'
Describe the issue
Following the documentation, I dynamically quantiized a resnet based model. The model is quantized and saved without error. However, when I try to create an inference session using the quantized model, the code crashes with the following error.
>>> ort_session = ort.InferenceSession(int8_path, providers=['CPUExecutionProvider'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/chinmay/anaconda3/envs/v_pytorch2/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 360, in __init__
self._create_inference_session(providers, provider_options, disabled_optimizers)
File "/home/chinmay/anaconda3/envs/v_pytorch2/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 408, in _create_inference_session
sess.initialize_session(providers, provider_options, disabled_optimizers)
onnxruntime.capi.onnxruntime_pybind11_state.NotImplemented: [ONNXRuntimeError] : 9 : NOT_IMPLEMENTED : Could not find an implementation for ConvInteger(10) node with name 'Conv_0_quant'
This is a duplicate of #12558 , which was closed a few months ago so I guess the support should have been added in onnxruntime, but I am still getting the same error.
To reproduce
import onnx
from onnxruntime.quantization import quantize_dynamic, QuantType
model_fp32 = 'path/to/the/model.onnx'
model_quant = 'path/to/the/model.quant.onnx'
quantized_model = quantize_dynamic(model_fp32, model_quant)
import onnxruntime as ort
ort_session = ort.InferenceSession(model_quant, providers=['CPUExecutionProvider'])
Urgency
Not very urgent, but not too low priority also.
Platform
Linux
OS Version
Ubuntu 20.04
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
1.14.1
ONNX Runtime API
Python
Architecture
X64
Execution Provider
Default CPU
Execution Provider Library Version
No response
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 14
- Comments: 29 (2 by maintainers)
same error, it only works with QUint8 but not QInt8
On the similar issue #3130, there is comment that may temporarily solve the issue. But when we change
weight_type=QuantType.QInt8toQuantType.QUInt8, the onnx quantized model seems to perform slower, as also mentioned in that issue. And that also happened to me.Beside, I think these issues happen due to onnx does not support
ConvIntegerfor signedInt8datatype, here.In ONNX Runtime docs, in Method Selection subsection, they said that:
So I tried to follow the an end-to-end example given in the docs, and somehow it worked, the weights are
int8. Here are steps that I did:CalibrationDataReaderby using some facial images.quantize_static()Same issue for segformer model
NotImplemented: [ONNXRuntimeError] : 9 : NOT_IMPLEMENTED : Could not find an implementation for ConvInteger(10) node with name '/segformer/encoder/patch_embeddings.0/proj/Conv_quant'I found a workaround to solve this, by setting:
Here,
nodes_to_excludeshould be the list of conv layer name in your model. You may find it in the error message when loading the model usingInferenceSession. For example, for the error message mentioned in the title of this issue, it would be: ‘Conv_0_quant’.I’m having the same issue. Can I help get the patch applied?
And what is the inference speed @abaoxomtieu ? In my use case, partial quantization gets slower than non-quantized model on CPU.
I fixed it by excluding the failed nodes. Most of the failures were in the IntergerConv nodes.
find node
delete
_quant/model/patch_embed/proj/Conv_quant => /model/patch_embed/proj/Conv
I have the same problem. I am finding that onnxruntime does not support the ConvInteger layer unfortunately, that means dynamic quantization is not working in onnxruntime if initial model has CNNs inside. Very sad!