Git Product home page Git Product logo

openvino_pytorch_layers's Introduction

โš ๏ธ Source code will be continued to be supported and developed in OpenVINO contrib. Thanks for all who used.


Repository with guides to enable some layers from PyTorch in Intel OpenVINO:

CI

OpenVINO Model Optimizer extension

To create OpenVINO IR, use extra --extension flag to specify a path to Model Optimizer extensions that perform graph transformations and register custom layers.

mo --input_model model.onnx --extension openvino_pytorch_layers/mo_extensions

Custom CPU extensions

You also need to build CPU extensions library which actually has C++ layers implementations:

source /opt/intel/openvino_2022/setupvars.sh

cd user_ie_extensions
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release && make -j$(nproc --all)

Add compiled extensions library to your project:

from openvino.runtime import Core

core = Core()
core.add_extension('user_ie_extensions/build/libuser_cpu_extension.so')

model = ie.read_model('model.xml')
compiled_model = ie.compile_model(model, 'CPU')

openvino_pytorch_layers's People

Contributors

dkurt avatar likholat avatar ngaloppo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

openvino_pytorch_layers's Issues

Question about Standalone Operation

Once I convert the PyTorch model to ONNX -- Can I run the converted model (involving grid_sample) standalone without any dependency on this openvino_pytorch_layers package?

Does the grid_sample operation support other arguments?

Hi, @dkurt
Thanks for your sharing! I wonder whether this op works for other arguments?
For example, F.grid_sample(img, grid, mode='bilinear', padding_mode='reflection', align_corners=True).

Will it be supported in iGPU in the future?

Best regards,
DwenGu

[ ERROR ] There is no registered "infer" function for node "Unpooling_53" with op = "Unpooling". Please implement this function in the extensions.

Hi @dkurt ,
Your solution to overcome a pytorch to IR model conversion issue here was really helpful, however we couldn't proceed with the PR due to dataset license issues. I am facing issue with model conversion in another model, this time it is due to maxunpooling layer in the decoder. I came across your really good extension. However, I am still not able to resolve the problem.

Receiving the following the error while converting model with maxunpool.

[ ERROR ]  Cannot infer shapes or values for node "Unpooling_53".
[ ERROR ]  There is no registered "infer" function for node "Unpooling_53" with op = "Unpooling". Please implement this function in the extensions. 
 For more information please refer to Model Optimizer FAQ, question #37. (https://docs.openvino.ai/latest/openvino_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html?question=37#question-37)
[ ERROR ]  
[ ERROR ]  It can happen due to bug in custom shape infer function <UNKNOWN>.
[ ERROR ]  Or because the node inputs have incorrect values/shapes.
[ ERROR ]  Or because input shapes are incorrect (embedded to the model or passed via --input_shape).
[ ERROR ]  Run Model Optimizer with --log_level=DEBUG for more information.
[ ERROR ]  Exception occurred during running replacer "REPLACEMENT_ID" (<class 'openvino.tools.mo.middle.PartialInfer.PartialInfer'>): Stopped shape/value propagation at "Unpooling_53" node. 
 For more information please refer to Model Optimizer FAQ, question #38. (https://docs.openvino.ai/latest/openvino_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html?question=38#question-38)

Input shape provided in mo is [1,1,512,512].

Environment Specs:

torch==1.12.0
torchvision==0.13.0
numpy==1.19.5
openvino-dev[onnx]==2022.1.0
onnxruntime==1.10.0

You can find the model definition, model weights, onnx file, error and debug log from mo here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.