openvinotoolkit / openvino

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

Can't convert model using custom operations #18713

Open Satmaks opened 1 year ago

Satmaks commented 1 year ago
Detailed description

Guys, I spent several days on this, read the documentation several times, I really hope for your help, please help, what am I doing wrong?

Previously, I used version 2020.3.0 and in order to make my model work with a custom operation, I patched OpenVINO like this: aecc8a71be73e5b928c343cef869fa81c04a1c9d.zip

Now, for version 2023.0.0, I first need to convert the model with a custom operation, and then use the inference of the model.

  1. I installed openvino-runtime. (Please reopen my other question).

  2. I built the module as written here. I did as written here. Source code of my module: srelu.zip Please tell me if everything is correct at this stage? Is this the same as what I wrote for version 2020.3.0?

  3. To convert the model, I use the model optimizer via the Python API and get the error:

    
    Traceback (most recent call last):                                                                                                                                                                                                                                                        
    File "....py", line 116, in main                                                                                                                                                                                  
    ov_model = convert_model(input_model=onnx_path, use_new_frontend=True, compress_to_fp16=True, static_shape=True, extensions="libopenvino_srelu_extension.so")                                                                                              
    File ".../.env3/lib/python3.9/site-packages/openvino/tools/mo/convert.py", line 348, in convert_model                                                                                                                               
    ov_model, _ = _convert(cli_parser, framework, params, True)                                                                                                                                                                                                                           
    File ".../.env3/lib/python3.9/site-packages/openvino/tools/mo/convert_impl.py", line 972, in _convert                                                                                                                               
    raise e.with_traceback(None)                                                                                                                                                                                                                                                          
    RuntimeError: Check 'false' failed at src/frontends/onnx/frontend/src/core/graph.cpp:378:                                                                                                                                                                                                 
    While validating ONNX node '<Node(SRelu): 156>':                                                                                                                                                                                                                                          
    Check 'false' failed at /opt/intel/openvino_2023.0.0/runtime/include/openvino/frontend/extension/op.hpp:214:                                                                                                                                                                              
    Check 'data != nullptr' failed at /opt/intel/openvino_2023.0.0/runtime/include/openvino/core/attribute_adapter.hpp:112:                                                                                                                                                                   
    Data conversion is not possible. Empty data is provided.                                                                                                                                                                                                                                  

Value for attribute "threshold_right" is not set or mapping between framework and openvino node attributes is incorrect.


Since I did not understand if I wrote the module in point 2 correctly, I removed these lines:
```.cpp
visitor.on_attribute("threshold_right", weights_threshold_right_);
visitor.on_attribute("slope_right", weights_slope_right_);
visitor.on_attribute("threshold_left", weights_threshold_left_);
visitor.on_attribute("slope_left", weights_slope_left_);

I was able to convert the model, but where do I get these arguments now? I assume that I deleted these lines in vain, initially I did everything right, but why does the error occur in poin 3? Help me please.

Jay-sanjay commented 1 year ago

Hey , I think the error occurred because you deleted the certain lines of code related to attributes in the module

Jay-sanjay commented 1 year ago

I think to resolve that issue you might need to restore those lines of code in the custom operation module and rebuild it.

Satmaks commented 1 year ago

@Jay-sanjay Hello, I think so too, but I get this error:

Traceback (most recent call last):                                                                                                                                                                                                                                                        
  File "....py", line 116, in main                                                                                                                                                                                  
    ov_model = convert_model(input_model=onnx_path, use_new_frontend=True, compress_to_fp16=True, static_shape=True, extensions="libopenvino_srelu_extension.so")                                                                                              
  File ".../.env3/lib/python3.9/site-packages/openvino/tools/mo/convert.py", line 348, in convert_model                                                                                                                               
    ov_model, _ = _convert(cli_parser, framework, params, True)                                                                                                                                                                                                                           
  File ".../.env3/lib/python3.9/site-packages/openvino/tools/mo/convert_impl.py", line 972, in _convert                                                                                                                               
    raise e.with_traceback(None)                                                                                                                                                                                                                                                          
RuntimeError: Check 'false' failed at src/frontends/onnx/frontend/src/core/graph.cpp:378:                                                                                                                                                                                                 
While validating ONNX node '<Node(SRelu): 156>':                                                                                                                                                                                                                                          
Check 'false' failed at /opt/intel/openvino_2023.0.0/runtime/include/openvino/frontend/extension/op.hpp:214:                                                                                                                                                                              
Check 'data != nullptr' failed at /opt/intel/openvino_2023.0.0/runtime/include/openvino/core/attribute_adapter.hpp:112:                                                                                                                                                                   
Data conversion is not possible. Empty data is provided.                                                                                                                                                                                                                                  

Value for attribute "threshold_right" is not set or mapping between framework and openvino node attributes is incorrect.

I don't understand why this is happening.

avitial commented 11 months ago

@gkrivor gentle ping.

github-actions[bot] commented 2 months ago

This issue will be closed in a week because of 9 months of no activity.

andrei-kochin commented 2 months ago

@Satmaks hello! Sorry for the long delay

Is this issue still actual for you?