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]: Keras UpSampling2D conversion crashed when input type as int16 #20838

Closed
3 tasks done
jikechao opened this issue Nov 2, 2023 · 4 comments · Fixed by #21870
Closed
3 tasks done

[Bug]: Keras UpSampling2D conversion crashed when input type as int16 #20838

jikechao opened this issue Nov 2, 2023 · 4 comments · Fixed by #21870
Assignees
Labels
bug Something isn't working category: TF FE OpenVINO TensorFlow FrontEnd

Comments

@jikechao
Copy link

jikechao commented Nov 2, 2023

OpenVINO Version

openvino-nightly 2023.2.0.dev20231101

Operating System

Ubuntu 18.04 (LTS)

Device used for inference

BATCH

Framework

Keras (TensorFlow 2)

Model used

self defined model shown in the following script

Issue description

OpenVINO crashed when the given Keras model containing UpSampling2D layer was converted to OpenVINO IR.
The crash happened at a type checking and threw "Input element type must be f32, f16, bf16, i8, u8, i64, i32". The check may skip the type of i16.

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.UpSampling2D()
input_shape = [1, 2, 3, 4]
input_data = np.random.randint(0, 1, size=input_shape)
weights = layer.get_weights()
layer.set_weights(weights)

x = layers.Input(shape=input_shape[1:], dtype="int16")
y = layer(x)
model = models.Model(x, y)
model.summary()
res_keras = model(input_data)
tf.saved_model.save(model, "tf_model")
ov_model = ov.convert_model("tf_model",  input=input_shape)

Relevant log output

Traceback (most recent call last):
  File "/home/shenqingchao/opera/OPERA/keras/fuzz/ov-bugs/bug3.py", line 19, in <module>
    ov_model = ov.convert_model("tf_model",  input=input_shape)
  File "/home/shenqingchao/.conda/envs/ov-latest/lib/python3.9/site-packages/openvino/tools/ovc/convert.py", line 101, in convert_model
    ov_model, _ = _convert(cli_parser, params, True)
  File "/home/shenqingchao/.conda/envs/ov-latest/lib/python3.9/site-packages/openvino/tools/ovc/convert_impl.py", line 535, in _convert
    raise e
  File "/home/shenqingchao/.conda/envs/ov-latest/lib/python3.9/site-packages/openvino/tools/ovc/convert_impl.py", line 478, in _convert
    ov_model = driver(argv, {"conversion_parameters": non_default_params})
  File "/home/shenqingchao/.conda/envs/ov-latest/lib/python3.9/site-packages/openvino/tools/ovc/convert_impl.py", line 230, in driver
    ov_model = moc_emit_ir(prepare_ir(argv), argv)
  File "/home/shenqingchao/.conda/envs/ov-latest/lib/python3.9/site-packages/openvino/tools/ovc/convert_impl.py", line 180, in prepare_ir
    ov_model = moc_pipeline(argv, moc_front_end)
  File "/home/shenqingchao/.conda/envs/ov-latest/lib/python3.9/site-packages/openvino/tools/ovc/moc_frontend/pipeline.py", line 247, in moc_pipeline
    ov_model = moc_front_end.convert(input_model)
  File "/home/shenqingchao/.conda/envs/ov-latest/lib/python3.9/site-packages/openvino/frontend/frontend.py", line 18, in convert
    converted_model = super().convert(model)
openvino._pyopenvino.OpConversionFailure: Check 'is_conversion_successful' failed at src/frontends/tensorflow/src/frontend.cpp:415:
FrontEnd API failed with OpConversionFailure:
[TensorFlow Frontend] Internal error, conversion is failed for ResizeNearestNeighbor operation with a message:
Check 'input_et == element::f32 || input_et == element::f16 || input_et == element::i8 || input_et == element::bf16 || input_et == element::u8 || input_et == element::i64 || input_et == element::i32 || input_et == element::dynamic' failed at src/core/src/op/util/interpolate_base.cpp:57:
While validating node 'opset11::Interpolate Interpolate_8 (input_1[0]:i16[1,2,3,4], model/up_sampling2d/mul[0]:i32[2], Constant_7[0]:i32[2]) -> (dynamic[...])' with friendly_name 'Interpolate_8':
Input element type must be f32, f16, bf16, i8, u8, i64, i32

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.
@jikechao jikechao added bug Something isn't working support_request labels Nov 2, 2023
@jikechao jikechao changed the title [Bug]: UpSampling2D crash when input type as int16 [Bug]: Keras UpSampling2D conversion crashed when input type as int16 Nov 2, 2023
@rkazants rkazants self-assigned this Nov 3, 2023
@rkazants
Copy link
Contributor

rkazants commented Nov 3, 2023

Hi @jikechao, thanks for reporting this bug. Indeed, the current loader for UpSampling2D supports limited set of input types. I will extended it to support i16 as well.

Best regards,
Roman

@rkazants
Copy link
Contributor

PR: #21870

@rkazants
Copy link
Contributor

Hi @jikechao, the fix was merged to the master. Please re-open if you have any concern.

Best regards,
Roman

@jikechao
Copy link
Author

@rkazants, thanks for your patch!

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
Development

Successfully merging a pull request may close this issue.

3 participants