Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.1k
Openvino backend for Executorch to enable inference on Intel CPUs, GPUs, NPUs#8573
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
86f685ebb12f60c9c8967f5bd832f3dc62ceec7831ca852debdddb169803bd8b1f38f87c4301407038140a769be0e6707d68a1cd44d1b4eb5c55a563c6d12329d8400379937e5806788916ba64e0b1bb79108770ecbe5e2d563e4ca4d7458197cdc2268255b83029112cda72bf7dc3e34324809d9d35e2c5ca5c454fac038a5abed415a3ec2424c727f877d411218a3f7e03c5b49e439d122f51aad2ac7050259b81460f37139bac58152a2c979f52541e44d996817832e7cc726f05f509a4ffb5d2784d61488d542155a17c66314c1fa9e2e2415af8cbb1174b60fb4e0cd6442a04ee6db7dc13de3f50b17fe62fc7e075870a3b2a5ea37c76beadb34dbe4440c07b70b086202cb91596d75672709b2dbd495303319cbc690892b9dd1aa425b9b604d9d07bbb2e6707d1a20242a980099e9bac9a209132b4a27c363a8c0330a981a668a20436b13915ae661a19de858e88f482344b8979b7d302ed3daf53685ceb1f1db517c159421f4d2ce36c96e788959283e7da0cd1a74ed92baa316cbdfc674b555971a928d1cbd06718ae15e20627e44514d4c0e6de60ea28fcf3fa8feacbb51412935e93783d1946e854ee00a18afd16201543e1a0615627c5ea9939311e63eff0e76d933b6fd8899c832b73431cfbb284e4ac8df2460512750275c47cec2fb053e7c17ee54b2f889e3138f702aabc29b46468c890a42185a751f087629d5a463fd3a26ce9321173970f213a0182fcceb234d1cf34f3df9ad89429bd81f921fb3685c7d5dd9679e5839ead3a85e30cc4c08205203e8e9a11d37c5c574d2b09251dcfba711cf634b7e8473b92ee78358162d719e8a8b3db49e2792cff39cd5154ad64685a370efa875db281b694a351e4f8ca40d47e3d94263a121d975c71d756e637b56f84902c8a3539dd7ae3a9e759c90ea8b9f76ef30ee76ee032ace76c4403e17d09c1ad164a02855f4eee40d7e7711fe0ad620293b1d593adab7d743bc069c1902ca3ec9cab0cb8882866dbb1756d12cf3ecfe3ceba03d538de24e823fe0bd72ac884129e04c874f5619e1d1be27e1f0cefc65aa7056f52a9a15178cedc2c72eb16060830c6821682ae800030fb9381a65db496425de4cef2a05e3c73a3e9125a2061928af4626258b423f53cc255d5b39a9010acf74e3e34bb3112bfb6768c01e67243060c0da55f42ecbae6050aa613dd050139dd9b26fc9c722468974ee3605f2bae693fFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #!/bin/bash | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| # All rights reserved. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
| set -ex | ||
| # shellcheck source=/dev/null | ||
| source "$(dirname "${BASH_SOURCE[0]}")/utils.sh" | ||
| git clone https://github.com/openvinotoolkit/openvino.git | ||
| cd openvino && git checkout releases/2025/1 | ||
| git submodule update --init --recursive | ||
| sudo ./install_build_dependencies.sh | ||
| mkdir build && cd build | ||
| cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=ON | ||
| make -j$(nproc) | ||
| cd .. | ||
| cmake --install build --prefix dist | ||
| source dist/setupvars.sh | ||
| cd ../backends/openvino | ||
| pip install -r requirements.txt | ||
| cd scripts | ||
| ./openvino_build.sh --enable_python |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/bash | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| # All rights reserved. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
| set -ex | ||
| # shellcheck source=/dev/null | ||
| source "$(dirname "${BASH_SOURCE[0]}")/utils.sh" | ||
| source openvino/dist/setupvars.sh | ||
| cd backends/openvino/tests | ||
| python test_runner.py --test_type ops | ||
| python test_runner.py --test_type models |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -29,6 +29,7 @@ Platform Support: | ||
| - Arm | ||
| - Cadence | ||
| - MediaTek | ||
| - OpenVINO | ||
| - Qualcomm | ||
| - Vulkan | ||
| - XNNPACK | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Copyright (c) Intel Corporation | ||
| # | ||
| # Licensed under the BSD License (the "License"); you may not use this file | ||
| # except in compliance with the License. See the license file found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
| # Set minimum required CMake version | ||
| cmake_minimum_required(VERSION 3.19) | ||
| # Set project name | ||
| project(openvino_backend_project) | ||
| # Set C++ standard | ||
| set(CMAKE_CXX_STANDARD 17) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
| # Ensure compile_commands.json is generated | ||
| set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
| # Set up EXECUTORCH_ROOT if not already set | ||
| if(NOT EXECUTORCH_ROOT) | ||
| set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) | ||
| endif() | ||
| # Define common include directories | ||
| set(COMMON_INCLUDE_DIRS ${EXECUTORCH_ROOT}/..) | ||
| # Include utility CMake scripts from ExecuteTorch | ||
| include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake) | ||
| # Find OpenVINO libraries | ||
| find_package(OpenVINO REQUIRED) | ||
| # Define OpenVINO backend as a static library | ||
| add_library(openvino_backend STATIC .) | ||
| # Enable exceptions and RTTI for OpenVINO backend | ||
| target_compile_options(openvino_backend PRIVATE -frtti -fexceptions) | ||
| # Include Executorch directories | ||
| target_include_directories(openvino_backend PUBLIC ${COMMON_INCLUDE_DIRS}) | ||
| # Link OpenVINO and ExecuteTorch core libraries | ||
| target_link_libraries(openvino_backend PRIVATE openvino::runtime executorch_core) | ||
| # Add source files for OpenVINO backend | ||
| target_sources(openvino_backend PRIVATE ${CMAKE_CURRENT_LIST_DIR}/runtime/OpenvinoBackend.cpp) | ||
| target_link_options_shared_lib(openvino_backend) | ||
| if(EXECUTORCH_BUILD_OPENVINO_EXECUTOR_RUNNER) | ||
| # Build executor runner binary for openvino backend | ||
| list(APPEND openvino_executor_runner_libs openvino_backend executorch) | ||
| set(_openvino_executor_runner__srcs | ||
| ${EXECUTORCH_ROOT}/examples/portable/executor_runner/executor_runner.cpp | ||
| ${EXECUTORCH_ROOT}/extension/data_loader/file_data_loader.cpp | ||
| ${EXECUTORCH_ROOT}/extension/evalue_util/print_evalue.cpp | ||
| ${EXECUTORCH_ROOT}/extension/runner_util/inputs.cpp | ||
| ${EXECUTORCH_ROOT}/extension/runner_util/inputs_portable.cpp | ||
| ) | ||
| add_executable(openvino_executor_runner ${_openvino_executor_runner__srcs}) | ||
| list(APPEND openvino_executor_runner_libs) | ||
| target_link_libraries( | ||
| openvino_executor_runner gflags portable_ops_lib ${openvino_executor_runner_libs} | ||
| ) | ||
| target_compile_options(openvino_executor_runner PUBLIC ${_common_compile_options}) | ||
| endif() | ||
| # Install OpenVINO backend library to the lib directory | ||
| install(TARGETS openvino_backend DESTINATION lib) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # OpenVINO Backend for ExecuTorch | ||
| The OpenVINO backend enables optimized execution of deep learning models on Intel hardware, leveraging Intel's [OpenVINO toolkit](https://www.intel.com/content/www/us/en/developer/tools/openvino-toolkit/overview.html) for inference acceleration. | ||
| ## Supported Hardware | ||
kimishpatel marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| OpenVINO backend supports the following hardware: | ||
| - Intel CPUs | ||
| - Intel integrated GPUs | ||
| - Intel discrete GPUs | ||
| - Intel NPUs | ||
| For more information on the supported hardware, please refer to [OpenVINO System Requirements](https://docs.openvino.ai/2025/about-openvino/release-notes-openvino/system-requirements.html) page. | ||
| ## Directory Structure | ||
| ``` | ||
| executorch | ||
| ├── backends | ||
| │ └── openvino | ||
| │ ├── runtime | ||
| │ ├── OpenvinoBackend.cpp | ||
| │ └── OpenvinoBackend.h | ||
| │ ├── scripts | ||
| │ └── openvino_build.sh | ||
| │ ├── tests | ||
| │ ├── CMakeLists.txt | ||
| │ ├── README.md | ||
| │ ├── __init__.py | ||
| │ ├── partitioner.py | ||
| │ ├── preprocess.py | ||
| │ └── requirements.txt | ||
| └── examples | ||
| └── openvino | ||
| ├── aot_optimize_and_infer.py | ||
| └── README.md | ||
| ``` | ||
| ## Build Instructions | ||
| ### Prerequisites | ||
| Before you begin, ensure you have openvino installed and configured on your system: | ||
ynimmaga marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ```bash | ||
| git clone https://github.com/openvinotoolkit/openvino.git | ||
| cd openvino && git checkout releases/2025/1 | ||
| git submodule update --init --recursive | ||
| sudo ./install_build_dependencies.sh | ||
| mkdir build && cd build | ||
| cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=ON | ||
| make -j$(nproc) | ||
| cd .. | ||
| cmake --install build --prefix <your_preferred_install_location> | ||
ynimmaga marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| cd <your_preferred_install_location> | ||
| source setupvars.sh | ||
| ``` | ||
| Note: The OpenVINO backend is not yet supported with the current OpenVINO release packages. It is recommended to build from source. The instructions for using OpenVINO release packages will be added soon. | ||
| For more information about OpenVINO build, refer to the [OpenVINO Build Instructions](https://github.com/openvinotoolkit/openvino/blob/master/docs/dev/build_linux.md). | ||
| ### Setup | ||
| Follow the steps below to setup your build environment: | ||
| 1. **Setup ExecuTorch Environment**: Refer to the [Environment Setup](https://pytorch.org/executorch/stable/getting-started-setup#environment-setup) guide for detailed instructions on setting up the ExecuTorch environment. | ||
| 2. **Setup OpenVINO Backend Environment** | ||
| - Install the dependent libs. Ensure that you are inside `executorch/backends/openvino/` directory | ||
| ```bash | ||
| pip install -r requirements.txt | ||
| ``` | ||
| Note: To achieve optimal performance with NNCF quantization, you should install the latest development version of NNCF (version 2.16.0.dev0+191b53d9 or higher). | ||
| 3. Navigate to `scripts/` directory. | ||
| 4. **Build OpenVINO Backend C++ Libraries and Executor Runner**: Once the prerequisites are in place, run the `openvino_build.sh` script to start the build process. By default, OpenVINO backend will be built under `cmake-out/backends/openvino/` as `libopenvino_backend.a` | ||
| ```bash | ||
| ./openvino_build.sh | ||
| ``` | ||
| **Build OpenVINO Backend Python Package with Pybindings**: To build and install the OpenVINO backend Python package with Python bindings, run the `openvino_build.sh` script with the `--enable_python` argument. This will compile and install the ExecuTorch Python package with the OpenVINO backend into your Python environment. This option will also enable python bindings required to execute OpenVINO backend tests and `export_and_infer_openvino.py` script inside `executorch/examples/openvino` folder. | ||
| ```bash | ||
| ./openvino_build.sh --enable_python | ||
| ``` | ||
| ### Run | ||
| Please refer to [README.md](../../examples/openvino/README.md) for instructions on running examples of various of models with openvino backend. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from .partitioner import OpenvinoPartitioner | ||
| from .preprocess import OpenvinoBackend | ||
| from .quantizer.quantizer import OpenVINOQuantizer | ||
| __all__ = ["OpenvinoBackend", "OpenvinoPartitioner", "OpenVINOQuantizer"] |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.