Open
Description
OpenVINO Version
2025.3.0-19357-ef1dae8b89d
Operating System
Ubuntu 20.04 (LTS)
Device used for inference
CPU
Framework
None
Model used
No response
Issue description
For the following onnx model,
it only contain an OneHot operator.
When I run this model using onnxruntime, the results are as follows:
ONNXRuntime:
[array([[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 1.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 1., 0.],
[0., 0., 0.],
[0., 0., 1.],
[0., 0., 0.],
[0., 1., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 1., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 1.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]]], dtype=float32)]
shape:
(10, 5, 3)
However, when I run it using openvino, the results are as follows:
OpenVINO:
[array([[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 1.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 1., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 1., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 1., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 1.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]]], dtype=float32)]
shape:
(10, 5, 3)
In the above results, the third block is different from that in the results produced by onnxruntime. Only two elements equals to 1, while there are 3 elements that equal to 1 in the onnxruntime's results. I also run this model using onnxruntime-gpu and tensorRT and the third block in the results are also containd 3 elements equaled to 1.
Step-by-step reproduction
This bug can be reproduced by the following code with the model in the attachment.
import sys
import os
import numpy as np
import onnx
import onnxruntime
import openvino as ov
import pickle
def main():
onnx_model = onnx.load("555.onnx")
with open("inputs.pkl", "rb") as fp:
inputs = pickle.load(fp)
try:
ort_session = onnxruntime.InferenceSession(
onnx_model.SerializeToString(), providers=["CPUExecutionProvider"]
)
ort_output = ort_session.run([], inputs)
except Exception as e:
print(e)
sys.exit(1)
print("ONNXRuntime:\n", ort_output)
print("shape:\n", ort_output[0].shape)
ov_model = ov.convert_model("555.onnx")
ir_path = "_temp_OVIR_555.xml"
ov.save_model(ov_model, ir_path)
core = ov.Core()
model = core.read_model(ir_path)
compiled_model = core.compile_model(model=model, device_name='CPU')
output_key = compiled_model.outputs
ov_output = []
for output in output_key:
ov_output.append(compiled_model(inputs)[output])
print("OpenVINO:\n", ov_output)
print("shape:\n", ov_output[0].shape)
np.testing.assert_allclose(ov_output, ort_output, rtol=0.1, atol=0.1)
if __name__ == "__main__":
main()
Relevant log output
Issue submission checklist
- I'm reporting an issue. It's not a question.
- I checked the problem with the documentation, FAQ, open issues, Stack Overflow, etc., and have not found a solution.
- There is reproducer code and related data files such as images, videos, models, etc.