How to convert the NodeArg type property into numpy dtype? #19607
-
I would like to check with onnxruntime what the input type of the tensors are. This can be done by using Openvino for example has a neat function to convert from openvino format into numpy dtype. Is there somethig similar in onnxruntime to convert |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Not aware of anything being defined in the ORT python library as it seems like a slightly unusual use-case. Given you need to provide valid input to run the model, why would you not know the type of that data and/or the details of the model inputs? FWIW models can be viewed in Netron and the input/output data types are shown there. You can create a fairly simple lookup table like this: Or alternatively use the ONNX python library to read the model input details. import onnx
m = onnx.load('model.onnx')
for i in m.graph.input:
if i.type.HasField('tensor_type'):
print(i.type.tensor_type.elem_type) Data type values are defined here: https://github.com/onnx/onnx/blob/c95a59c4754e40f0eb33174d7dfe5e2b9bd0ed7f/onnx/onnx.proto#L497-L542 |
Beta Was this translation helpful? Give feedback.
-
The string is what ONNX uses. Not sure why. |
Beta Was this translation helpful? Give feedback.
Not aware of anything being defined in the ORT python library as it seems like a slightly unusual use-case. Given you need to provide valid input to run the model, why would you not know the type of that data and/or the details of the model inputs?
FWIW models can be viewed in Netron and the input/output data types are shown there.
You can create a fairly simple lookup table like this:
onnxruntime/onnxruntime/python/tools/transformers/models/whisper/whisper_helper.py
Lines 371 to 378 in 430a086