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]: Expected numpy type or openvino.runtime.Type, got <class 'NoneType'>. #20731

Closed
3 tasks done
jikechao opened this issue Oct 27, 2023 · 2 comments · Fixed by #20735
Closed
3 tasks done

[Bug]: Expected numpy type or openvino.runtime.Type, got <class 'NoneType'>. #20731

jikechao opened this issue Oct 27, 2023 · 2 comments · Fixed by #20735
Assignees
Labels
bug Something isn't working category: PyTorch FE OpenVINO PyTorch Frontend support_request
Milestone

Comments

@jikechao
Copy link

jikechao commented Oct 27, 2023

OpenVINO Version

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

Operating System

Ubuntu 18.04 (LTS)

Device used for inference

CPU

Framework

PyTorch

Model used

No response

Issue description

OpenVINO converts PyTorch model will crash when input_data is torch.int16.
It triggered an assertion error and reported "Got incorrect format of input types. Expected numpy type or openvino.runtime.Type, got <class 'NoneType'>."

As a comparison, torch.int8 and torch.int32 can be identified and the model can be converted into OV IR correctly.

Step-by-step reproduction

import torch
import openvino as ov

torch_model = torch.nn.ReLU6(inplace=False,).eval()

input_data = torch.randint(1, 100, [10, 15, 2], dtype=torch.int16)  # only torch.int16 can trigger this crash.
trace = torch.jit.trace(torch_model, input_data)
trace = torch.jit.freeze(trace)
input_shapes = input_data.shape
print(input_shapes)

ov_model = ov.convert_model(trace, example_input=input_data)
ir_path = f"_temp_model/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")
output_key = compiled_model.output(0)
result = compiled_model(input_data)[output_key]

Relevant log output

Traceback (most recent call last):
  File "test_demo.py", line 12, in <module>
    ov_model = ov.convert_model(trace, example_input=input_data)
  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 76, in moc_pipeline
    argv.placeholder_shapes, argv.placeholder_data_types = convert_params_lists_to_dicts(
  File "C:\software\conda\envs\torch\lib\site-packages\openvino\tools\ovc\moc_frontend\extractor.py", line 407, in convert_params_lists_to_dicts
    assert isinstance(node_type, (type, np.dtype, Type)), "Got incorrect format of input types. " \
AssertionError: Got incorrect format of input types. Expected numpy type or openvino.runtime.Type, got <class 'NoneType'>.

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.
@mvafin
Copy link
Contributor

mvafin commented Oct 27, 2023

Thank you very much for your findings. This issue was caused because int16 was omitted from dictionary.

@ilya-lavrenov ilya-lavrenov added this to the 2023.2 milestone Oct 27, 2023
@jikechao
Copy link
Author

@mvafin Thanks for your PR.

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: PyTorch FE OpenVINO PyTorch Frontend support_request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants