openvino
openvino copied to clipboard
[Bug]: Inconsistency output produced between OpenVINO and ONNXRuntime
OpenVINO Version
openvino-nightly 2023.2.0.dev20231101
Operating System
Ubuntu 18.04 (LTS)
Device used for inference
BATCH
Framework
ONNX
Model used
https://github.com/jikechao/onnx_models/blob/main/SoftmaxCrossEntropyLoss.onnx
Issue description
The given model produces inconsistent predicted results with ONNXRuntime.
Step-by-step reproduction
Step 1: Download the given model and put it into the same directory with the following script
Step 2: Run the following script:
import onnxruntime as ort
import openvino as ov
import numpy as np
onnx_model_path = './SoftmaxCrossEntropyLoss.onnx'
session = ort.InferenceSession(onnx_model_path)
input_x = np.random.random([3, 5]).astype(np.float32)
input_y = np.random.randint(0, 2, size=[3], dtype=np.int64)
input_w = np.random.random([5]).astype(np.float32)
input_data = {"x": input_x, "y": input_y, "w": input_w}
output_name = session.get_outputs()[0].name
onnx_output = session.run(None, input_data)
ov_model = ov.convert_model(onnx_model_path)
ir_path = f"temp_OVIR.xml"
ov.save_model(ov_model, ir_path, compress_to_fp16=False)
core = ov.Core()
model = core.read_model(ir_path)
compiled_model = core.compile_model(model=model, device_name="CPU")
# show the model structure
# input_key = compiled_model.input(0)
output_key = compiled_model.outputs
# network_input_shape = input_key.shape
for i, output in enumerate(output_key):
ov_output = compiled_model(input_data)[output]
np.testing.assert_allclose(onnx_output[i], ov_output, atol=1e-3)
Relevant log output
AssertionError:
Not equal to tolerance rtol=1e-07, atol=0.001
Mismatched elements: 1 / 3 (33.3%)
Max absolute difference: 1.3612924
Max relative difference: 8.530946e-08
x: array([1.397375, 1.326354, 1.361292], dtype=float32)
y: array([ 1.397375, 1.326354, -0. ], dtype=float32)
Issue submission checklist
- [X] I'm reporting an issue. It's not a question.
- [X] I checked the problem with the documentation, FAQ, open issues, Stack Overflow, etc., and have not found a solution.
- [X] There is reproducer code and related data files such as images, videos, models, etc.