Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Check 'm_element_type != element::undefined && m_element_type.is_static()' failed #20811

Closed
jikechao opened this issue Nov 1, 2023 · 7 comments · Fixed by #21439 or #21864
Closed
Assignees
Labels
bug Something isn't working category: TF FE OpenVINO TensorFlow FrontEnd

Comments

@jikechao
Copy link

jikechao commented Nov 1, 2023

OpenVINO Version

2023.1.0-12185-9e6b00e51cd-releases/2023/1

Operating System

Ubuntu 18.04 (LTS)

Framework

Tensorflow/Keras

Model used

Given in the following script

Issue description

When the input layer`s dtype="uint16" or "uint32", the conversion process from the given Keras model to OpenVINO will crash unexpectedly.

As a comparison, other input types (e.g., int16, 'uint8') can converted very well.

Step-by-step reproduction

import tensorflow as tf
from tensorflow import keras as keras
from tensorflow.keras import layers, models
import numpy as np

import openvino as ov

layer = keras.layers.ReLU()
input_shape = [1, 2, 3, 4]
input_data = np.random.randint(2, size=input_shape)
# weights = layer.get_weights()
# layer.set_weights(weights)

x = layers.Input(shape=input_shape[1:], dtype="uint16")
y = layer(x)
model = models.Model(x, y)
# model.summary()
res_keras = model(input_data)

tf2_model_path = f"_temp_model"
tf.saved_model.save(model, tf2_model_path)
ov_model = ov.convert_model(tf2_model_path,  input=input_shape)

Relevant log output

Traceback (most recent call last):
  File "test.py", line 24, in <module>
    ov_model = ov.convert_model(tf2_model_path,  input=input_shape)
  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 'm_element_type != element::undefined && m_element_type.is_static()' failed at src\inference\src\dev\make_tensor.cpp:34


Process finished with exit code 1


### 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.
@jikechao jikechao added bug Something isn't working support_request labels Nov 1, 2023
@jikechao jikechao changed the title [Bug]: [Bug]: Check 'm_element_type != element::undefined && m_element_type.is_static()' failed Nov 1, 2023
@rkazants rkazants self-assigned this Nov 1, 2023
@rkazants rkazants added the category: TF FE OpenVINO TensorFlow FrontEnd label Nov 1, 2023
@rkazants
Copy link
Contributor

rkazants commented Nov 1, 2023

Hi @jikechao, thanks for reporting this bug. Indeed, this bug can still exists according the current state of type mapping: https://github.com/openvinotoolkit/openvino/blob/master/src/frontends/tensorflow/src/tf_utils.cpp#L154

I will fix it.

Best regards,
Roman

@jikechao
Copy link
Author

jikechao commented Nov 1, 2023

BTW, "uint16", "uint32", and "uint64" have the same crash message.

@rkazants
Copy link
Contributor

rkazants commented Nov 1, 2023

BTW, "uint16", "uint32", and "uint64" have the same crash message.

Yes, these types are also absent in that type map.

Thanks,
Roman

@rkazants
Copy link
Contributor

rkazants commented Dec 5, 2023

Hi @jikechao,

#21439 is solving the problem. Please check and close if no concern.

Best regards,
Roman

@jikechao
Copy link
Author

jikechao commented Dec 5, 2023

@rkazants Thanks for your fixing.

@andrei-kochin
Copy link
Contributor

Re-opening original case as fix caused regression and we have to temporary revert #21656 to further improve the fix.

@rkazants
Copy link
Contributor

rkazants commented Dec 25, 2023

The problem was with incorrect unpacking of compressed fp16 constant and PRelu fusing transformation was not applied due to incorrect fp16 Constant. Now I recover this PR and apply fix for this.
PR: #21864

Best regards,
Roman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working category: TF FE OpenVINO TensorFlow FrontEnd
Projects
4 participants