openvinotoolkit / openvino

OpenVINO™ is an open-source toolkit for optimizing and deploying AI inference
https://docs.openvino.ai
Apache License 2.0
7.01k stars 2.21k forks source link

[Bug]: Dimension of data input shape along 'axis': 7 must be evenly divisible by 'num_splits' attribute value: 4 #21175

Open jikechao opened 10 months ago

jikechao commented 10 months ago

OpenVINO Version

openvino-nightly 2023.2.0.dev20231101

Operating System

Ubuntu 18.04 (LTS)

Device used for inference

CPU

Framework

ONNX

Model used

https://github.com/jikechao/onnx_models/blob/main/Split.onnx

Issue description

image

For the special case, ONNXRuntime can support it and give correct calculation results. However, the conversion from ONNX to OV IR crashed. This is caused by incorrect constraint checking, like Dimension of data input shape along 'axis': 7 must be evenly divisible by 'num_splits' attribute value: 4

Step-by-step reproduction

download the given model and convert it to OV IR.

import openvino as ov

onnx_model_path = 'Split.onnx'
ov_model = ov.convert_model(onnx_model_path)

Relevant log output

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    ov_model = ov.convert_model(onnx_model_path)
  File "C:\software\conda\envs\torch\lib\site-packages\openvino\tools\ovc\convert.py", line 101, in convert_model
    ov_model, _ = _convert(cli_parser, params, True)
  File "C:\software\conda\envs\torch\lib\site-packages\openvino\tools\ovc\convert_impl.py", line 524, in _convert
    raise e
  File "C:\software\conda\envs\torch\lib\site-packages\openvino\tools\ovc\convert_impl.py", line 476, in _convert
    ov_model = driver(argv, {"conversion_parameters": non_default_params})
  File "C:\software\conda\envs\torch\lib\site-packages\openvino\tools\ovc\convert_impl.py", line 226, in driver
    ov_model = moc_emit_ir(prepare_ir(argv), argv)
  File "C:\software\conda\envs\torch\lib\site-packages\openvino\tools\ovc\convert_impl.py", line 172, in prepare_ir
    ov_model = moc_pipeline(argv, moc_front_end)
  File "C:\software\conda\envs\torch\lib\site-packages\openvino\tools\ovc\moc_frontend\pipeline.py", line 247, in moc_pipeline
    ov_model = moc_front_end.convert(input_model)
  File "C:\software\conda\envs\torch\lib\site-packages\openvino\frontend\frontend.py", line 18, in convert
    converted_model = super().convert(model)
RuntimeError: Check 'error_message.empty()' failed at src\frontends\onnx\frontend\src\frontend.cpp:124:
Errors during ONNX translation: 
While validating ONNX node '<Node(Split): output_1, output_2, output_3, output_4>':
Check 'dimension_at_axis % num_splits == 0' failed at src\core\shape_inference\include\split_shape_inference.hpp:62:
While validating node 'opset1::Split Split_3 (input[0]:f32[7], Constant_2[0]:i64[]) -> (dynamic[...])' with friendly_name 'Split_3':
Dimension of data input shape along 'axis': 7 must be evenly divisible by 'num_splits' attribute value: 4

Issue submission checklist

jikechao commented 10 months ago

@avitial @andrei-kochin @gkrivor This issue has been open for more than 2 weeks, Could you help me a look?

From my perspective, ONNXRuntime can accept this behavior while OV cannot, we should correct the 'Split' operator in OV to keep it aligned with ONNXRuntime.

Wish your reply! Thank you!

andrei-kochin commented 10 months ago

@jikechao appreciate your patience!

I agree that current behavior is not aligned with ONNX RT but what can help us to prioritize this issue higher is that if you can find some real model in public which suffers from this issue. As per pool of existing models in our validation and other known models we don't see similar cases so we consider this bug as the corner case which doesn't require immediate actions.

Currently we are focused on higher priority activities. Could you please provide some justification to increase the priority if you think that it is critical? And of course there is always a way to contribute the fix for this on your own and we can assist you with it.

Thank you!

andrei-kochin commented 5 months ago

Currently ONNX RT allows invalid dimensions for Split op even if tensor size is not possible to be divided while OpenVINO doesn't allow that

>>> input
array([1.7858912e+31, 2.9642022e+29, 1.5645358e+04, 7.2249586e+28,
       1.0102059e-38, 0.0000000e+00, 0.0000000e+00], dtype=float32)
>>> sess.run([], {'input': input})
[
array([1.7858912e+31, 2.9642022e+29], dtype=float32), 
array([1.5645358e+04, 7.2249586e+28], dtype=float32),
array([1.0102059e-38, 0.0000000e+00], dtype=float32),
array([0.], dtype=float32)
]