microsoft / microsoft/onnxruntime
'Conv' operator doesn't support Double tensor type on runtime
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 21.9k
- Forks
- 4.2k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 179
Description
Describe the bug
When using 'Conv' operator with Double Tensor type the following error occurs:
Traceback (most recent call last):
File ".\onnx_fix_run.py", line 19, in <module>
sess = rt.InferenceSession("onnx_check.onnx", so)
File "C:\python\x64\python37\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 280, in __init__
self._create_inference_session(providers, provider_options)
File "C:\python\x64\python37\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 312, in _create_inference_session
sess.initialize_session(providers, provider_options)
onnxruntime.capi.onnxruntime_pybind11_state.NotImplemented: [ONNXRuntimeError] : 9 : NOT_IMPLEMENTED : Could not find an implementation for the node Conv(1)
Urgency
Moderate
System information
Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)] on win32
onnx: 1.9.0
onnxruntime: 1.7.0
onnxmltools: 1.7.0
To Reproduce
Please use the following example code to build model:
import onnx, numpy as np, onnxmltools
from onnx import helper, TensorProto
type = TensorProto.DOUBLE #by setting to TensorProto.FLOAT it works fine
X = helper.make_tensor_value_info('X', type, [1, 1, 5, 5]) #input
W = helper.make_tensor_value_info('W', type, [1, 1, 3, 3]) #input
Y = helper.make_tensor_value_info('Y', type, [1, 1, 3, 3]) #output
node_def = helper.make_node('Conv', ['X', 'W'], ['Y'], auto_pad='SAME_LOWER', kernel_shape=[3, 3], strides=[2, 2],)
graph_def = helper.make_graph([node_def], 'onnx_check', [X, W], [Y],)
model_def = helper.make_model_gen_version(graph_def, producer_name='onnx_check')
## remove opset 13 and set it to 11 (latest for Conv as per docs)
model_def.opset_import.pop()
info = model_def.opset_import.add()
info.version = 11 #by setting this to 9, for example, we get 'Could not find an implementation for the node Conv(1)'
onnxmltools.utils.save_model(model_def, "onnx_check.onnx")
onnx.checker.check_model(model_def) #okay for both types
print('The model is checked!')
Please use the following example code to run model:
import numpy as np, onnxruntime as rt
np_type = np.float64 #set to np.float32 when using tensor type FLOAT (works fine in that case)
x = np.array([[[[0., 1., 2., 3., 4.],
[5., 6., 7., 8., 9.],
[10., 11., 12., 13., 14.],
[15., 16., 17., 18., 19.],
[20., 21., 22., 23., 24.]]]]).astype(np_type)
w = np.array([[[[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]]]]).astype(np_type)
inputs = { "X": x, "W": w }
## load and predict
so = rt.SessionOptions()
so.graph_optimization_level = rt.GraphOptimizationLevel.ORT_ENABLE_ALL #ORT_DISABLE_ALL gives same result
sess = rt.InferenceSession("onnx_check.onnx", so)
outputs = [ o.name for o in sess.get_outputs() ]
result = sess.run(outputs, inputs)
print(result)
Expected behavior
As described in this document, ONNX should support tensor(double) type for Conv
Can you please check this issue? If there's any fix, workaround, alternative or pointers to where I can add/implement this feature I will be happy to contribute
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied Python reproduction with onnxruntime 1.7.0 and compare FLOAT versus DOUBLE for the Conv node. Trace the Conv runtime implementation and its existing type coverage; done means the DOUBLE model loads and inference returns output without the NOT_IMPLEMENTED error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- backend, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100