openvinotoolkit / openvino

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

[Bug]: Cannot get length of dynamic dimension #21177

Open jikechao opened 8 months ago

jikechao commented 8 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/Pads.onnx

Issue description

The conversion of the Pads operator from ONNX failed unexpectedly and threw "Cannot get length of dynamic dimension". The model structure is shown below: image

Step-by-step reproduction

import openvino as ov
import numpy as np
import onnxruntime as ort
onnx_model_path = 'Pads.onnx'
session = ort.InferenceSession(onnx_model_path)

x = np.random.random([1, 3, 4, 5]).astype(np.float32)
pads = np.random.randint(0, 2, size=[8], dtype=np.int64)
input_data = {"x": x, "pads": pads}
output_name = session.get_outputs()[0].name
onnx_output = session.run(None, input_data)

ov_model = ov.convert_model(onnx_model_path)  # crash

Relevant log output

Traceback (most recent call last):
  File "test.py", line 14, 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\moc_frontend\moc_emit_ir.py", line 18, in moc_emit_ir
    apply_moc_transformations(ngraph_function, cf=False, smart_reshape=True)
RuntimeError: Exception from src\core\src\dimension.cpp:233:
Cannot get length of dynamic dimension

Issue submission checklist

heebahsaleem commented 7 months ago

Is this issue resolved? I am getting the same issue

jikechao commented 6 months ago

@heebahsaleem This problem still exists and has not been resolved yet. @avitial @ilya-lavrenov could you help us investigate this issue?

wenjiew commented 6 months ago

@gkrivor a kind reminder to take a look into this issue. Thanks!

andrei-kochin commented 2 months ago

@jikechao @heebahsaleem issue can be workaround-ed if you use compile_model call directly without converting the model to IR. Seems like an issue in the transformation pipeline so I summon @itikhono to assign someone to take a look

>>> m = c.read_model("pads.onnx")
>>> m
<Model: 'Pad'
inputs[
<ConstOutput: names[x] shape[1,3,4,5] type: f32>,
<ConstOutput: names[pads] shape[8] type: i64>
]
outputs[
<ConstOutput: names[y] shape[?,?,?,?] type: f32>
]>

>>> c.compile_model(m)
<CompiledModel:
inputs[
<ConstOutput: names[x] shape[1,3,4,5] type: f32>,
<ConstOutput: names[pads] shape[8] type: i64>
]
outputs[
<ConstOutput: names[y] shape[?,?,?,?] type: f32>
]>
Plomo-02 commented 1 month ago

hello, Is it possible being assigned to this issue?