Skip to content

Commit e12266e

Browse files
committed
Updated README
1 parent 70f9084 commit e12266e

1 file changed

Lines changed: 156 additions & 54 deletions

File tree

backends/openvino/README.md

Lines changed: 156 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,26 @@ For more information on the supported hardware, please refer to [OpenVINO System
1414

1515
## Quick Start (pip wheel)
1616

17-
On Linux, the OpenVINO backend is included in the ExecuTorch pip wheel. Install the OpenVINO runtime to activate it:
17+
On Linux and Windows, the OpenVINO backend is included in the ExecuTorch pip wheel. Install the OpenVINO runtime to activate it:
1818

1919
```bash
2020
pip install executorch[openvino]
2121
```
2222

23-
The backend automatically discovers the OpenVINO C library from the pip-installed package — no `LD_LIBRARY_PATH` setup is needed.
23+
The backend automatically discovers the OpenVINO C library from the pip-installed package — no `LD_LIBRARY_PATH` (Linux) or `PATH` (Windows) setup is needed.
2424

2525
If auto-discovery fails (e.g. non-standard install), you can point to the library explicitly:
2626

27+
**Linux:**
2728
```bash
2829
export OPENVINO_LIB_PATH=$(python3 -c "import openvino, os; print(os.path.join(os.path.dirname(openvino.__file__), 'libs', 'libopenvino_c.so'))")
2930
```
3031

32+
**Windows (PowerShell):**
33+
```powershell
34+
$env:OPENVINO_LIB_PATH = python -c "import openvino, os; print(os.path.join(os.path.dirname(openvino.__file__), 'libs', 'openvino_c.dll'))"
35+
```
36+
3137
Verify the backend is available:
3238

3339
```python
@@ -44,50 +50,169 @@ print(_get_registered_backend_names())
4450
executorch
4551
├── backends
4652
│ └── openvino
53+
│ ├── _passes
54+
│ │ ├── __init__.py
55+
│ │ └── decompose_floor_divide_pass.py
4756
│ ├── quantizer
48-
├── observers
49-
── nncf_observers.py
50-
├── __init__.py
51-
└── quantizer.py
57+
├── __init__.py
58+
── llm_compression.py
59+
├── observers.py
60+
└── quantizer.py
5261
│ ├── runtime
53-
├── OpenvinoApi.h
54-
├── OpenvinoBackend.cpp
55-
└── OpenvinoBackend.h
62+
├── OpenvinoApi.h
63+
├── OpenvinoBackend.cpp
64+
└── OpenvinoBackend.h
5665
│ ├── scripts
57-
│ └── openvino_build.sh
66+
│ │ └── openvino_build.sh
67+
│ ├── test
68+
│ │ └── tester
69+
│ │ ├── __init__.py
70+
│ │ └── tester.py
5871
│ ├── tests
72+
│ │ ├── models
73+
│ │ │ └── test_classification.py
74+
│ │ ├── ops
75+
│ │ │ ├── base_openvino_op_test.py
76+
│ │ │ └── test_*.py
77+
│ │ ├── quantizer
78+
│ │ │ ├── synthetic_test_models.py
79+
│ │ │ └── test_llm_compression.py
80+
│ │ ├── README.md
81+
│ │ └── test_runner.py
5982
│ ├── CMakeLists.txt
6083
│ ├── README.md
6184
│ ├── __init__.py
6285
│ ├── partitioner.py
6386
│ ├── preprocess.py
6487
│ └── requirements.txt
6588
└── examples
66-
└── openvino
67-
├── aot_optimize_and_infer.py
68-
└── README.md
89+
└── openvino # See examples/openvino/README.md
6990
```
7091

7192
## Build Instructions
7293

73-
### Prerequisites
94+
### Setup
95+
96+
Follow the steps below to setup your build environment:
97+
98+
99+
1. **Create a Virtual Environment**
100+
- Create a virtual environment and activate it by executing the commands below.
101+
102+
**Linux:**
103+
```bash
104+
python -m venv env
105+
source env/bin/activate
106+
```
107+
108+
**Windows (PowerShell):**
109+
```powershell
110+
python -m venv env
111+
env\Scripts\Activate.ps1
112+
```
113+
2. **Clone ExecuTorch Repository from Github**
114+
- On Windows, enable symlinks before cloning. Refer to [Building from Source](https://docs.pytorch.org/executorch/main/using-executorch-building-from-source.html#environment-setup) for more details.
115+
- Clone Executorch repository by executing the command below.
116+
```bash
117+
git clone --recurse-submodules https://github.com/pytorch/executorch.git
118+
```
119+
3. **Build ExecuTorch with OpenVINO Backend**
120+
- The following commands build and install ExecuTorch with the OpenVINO backend into `cmake-out`.
121+
122+
**Linux:**
123+
```bash
124+
cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
125+
-DCMAKE_BUILD_TYPE=Release \
126+
-DEXECUTORCH_BUILD_OPENVINO=ON \
127+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
128+
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
129+
-DEXECUTORCH_BUILD_EXTENSION_NAMED_DATA_MAP=ON \
130+
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
131+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
132+
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
133+
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \
134+
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
135+
-Bcmake-out
136+
cmake --build cmake-out --target install --config Release -j $(nproc)
137+
```
138+
139+
**Windows (PowerShell):**
140+
```powershell
141+
cmake -DCMAKE_INSTALL_PREFIX=cmake-out `
142+
-DCMAKE_BUILD_TYPE=Release `
143+
-DEXECUTORCH_BUILD_OPENVINO=ON `
144+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON `
145+
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON `
146+
-DEXECUTORCH_BUILD_EXTENSION_NAMED_DATA_MAP=ON `
147+
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON `
148+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON `
149+
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON `
150+
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON `
151+
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON `
152+
-Bcmake-out
153+
cmake --build cmake-out --target install --config Release -j $env:NUMBER_OF_PROCESSORS
154+
```
155+
156+
To additionally build with LLM extension support, append `-DEXECUTORCH_BUILD_EXTENSION_LLM=ON -DEXECUTORCH_BUILD_EXTENSION_LLM_RUNNER=ON` to the configure step.
157+
158+
#### Build Python Package with Pybindings
159+
160+
Compiles and installs the ExecuTorch Python package with the OpenVINO backend into your Python environment, enabling python bindings required to execute OpenVINO backend tests and `aot_optimize_and_infer.py` script inside `executorch/examples/openvino` folder.
161+
162+
**Linux:**
163+
```bash
164+
pip install -r backends/openvino/requirements.txt
165+
CMAKE_ARGS="-DEXECUTORCH_BUILD_OPENVINO=ON -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON" \
166+
CMAKE_BUILD_ARGS="--target openvino_backend" \
167+
./install_executorch.sh --use-pt-pinned-commit
168+
```
169+
- On Linux, `backends/openvino/scripts/openvino_build.sh` can be used as a convenience wrapper with `--enable_python`, `--cpp_runtime`, and `--cpp_runtime_llm` options instead of running the above commands directly.
170+
171+
**Windows (PowerShell):**
172+
```powershell
173+
pip install -r backends/openvino/requirements.txt
174+
$env:CMAKE_ARGS = "-DEXECUTORCH_BUILD_OPENVINO=ON -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON"
175+
$env:CMAKE_BUILD_ARGS = "--target openvino_backend"
176+
.\install_executorch.bat --use-pt-pinned-commit
177+
```
178+
179+
180+
181+
For more information about ExecuTorch environment setup, refer to the [Environment Setup](https://pytorch.org/executorch/main/getting-started-setup#environment-setup) guide.
182+
183+
## Runtime Setup
184+
185+
OpenVINO is a runtime-only dependency — it is not required at build time. The backend discovers and loads the OpenVINO C library dynamically when first used. You can provide the library via pip (recommended) or a manual install.
74186

75-
Before you begin, ensure you have openvino installed and configured on your system.
187+
### Install via pip (Recommended)
188+
189+
```bash
190+
pip install openvino
191+
```
76192

77193
### Use OpenVINO from Release Packages
78194

79195
1. Download the OpenVINO release package from [here](https://docs.openvino.ai/2025/get-started/install-openvino.html). Make sure to select your configuration and click on **OpenVINO Archives** under the distribution section to download the appropriate archive for your platform.
80196

81197
2. Extract the release package from the archive and set the environment variables.
82198

199+
**Linux:**
83200
```bash
84201
tar -zxf openvino_toolkit_<your_release_configuration>.tgz
85202
cd openvino_toolkit_<your_release_configuration>
86203
source setupvars.sh
87204
```
88205

206+
**Windows (PowerShell):**
207+
```powershell
208+
Expand-Archive openvino_toolkit_<your_release_configuration>.zip
209+
cd openvino_toolkit_<your_release_configuration>
210+
.\setupvars.ps1
211+
```
212+
89213
### (Optional) Build OpenVINO from Source
90214

215+
**Linux:**
91216
```bash
92217
git clone https://github.com/openvinotoolkit/openvino.git
93218
cd openvino
@@ -103,46 +228,23 @@ cd <your_preferred_install_location>
103228
source setupvars.sh
104229
```
105230

106-
For more information about OpenVINO build, refer to the [OpenVINO Build Instructions](https://github.com/openvinotoolkit/openvino/blob/master/docs/dev/build_linux.md).
107-
108-
### Setup
109-
110-
Follow the steps below to setup your build environment:
111-
112-
113-
1. **Create a Virtual Environment**
114-
- Create a virtual environment and activate it by executing the commands below.
115-
```bash
116-
python -m venv env
117-
source env/bin/activate
118-
```
119-
2. **Clone ExecuTorch Repository from Github**
120-
- Clone Executorch repository by executing the command below.
121-
```bash
122-
git clone --recurse-submodules https://github.com/pytorch/executorch.git
123-
```
124-
3. **Build ExecuTorch with OpenVINO Backend**
125-
- Ensure that you are inside `executorch/backends/openvino/scripts` directory. The following command builds and installs ExecuTorch with the OpenVINO backend, also compiles the C++ runtime libraries and binaries into `<executorch_root>/cmake-out` for quick inference testing.
126-
```bash
127-
openvino_build.sh
128-
```
129-
- Optionally, `openvino_build.sh` script can be used to build python package or C++ libraries/binaries seperately.
231+
**Windows (PowerShell):**
232+
```powershell
233+
git clone https://github.com/openvinotoolkit/openvino.git
234+
cd openvino
235+
git submodule update --init --recursive
236+
mkdir build; cd build
237+
cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=ON
238+
cmake --build . --config Release -j $env:NUMBER_OF_PROCESSORS
130239
131-
**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 as shown in the below command. 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 `aot_optimize_and_infer.py` script inside `executorch/examples/openvino` folder.
132-
```bash
133-
./openvino_build.sh --enable_python
134-
```
135-
**Build C++ Runtime Libraries for OpenVINO Backend**: Run the `openvino_build.sh` script with the `--cpp_runtime` flag to build the C++ runtime libraries as shown in the below command. The compiled libraries files and binaries can be found in the `<executorch_root>/cmake-out` directory. The binary located at `<executorch_root>/cmake-out/executor_runner` can be used to run inference with vision models.
136-
```bash
137-
./openvino_build.sh --cpp_runtime
138-
```
139-
**Build C++ Runtime Libraries with LLM Extension**: Run the `openvino_build.sh` script with the `--cpp_runtime_llm` flag to build the C++ runtime libraries with LLM extension as shown in the below command. Use this option instead of `--cpp_runtime` for LLM extension support which is required by LLM examples.
140-
```bash
141-
./openvino_build.sh --cpp_runtime_llm
142-
```
240+
cd ..
241+
cmake --install build --prefix <your_preferred_install_location>
242+
cd <your_preferred_install_location>
243+
.\setupvars.ps1
244+
```
143245

144-
For more information about ExecuTorch environment setup, refer to the [Environment Setup](https://pytorch.org/executorch/main/getting-started-setup#environment-setup) guide.
246+
For more information about OpenVINO build, refer to the [OpenVINO Build Instructions](https://github.com/openvinotoolkit/openvino/blob/master/docs/dev/build_linux.md).
145247

146-
### Run
248+
### Examples
147249

148-
Please refer to [README.md](../../examples/openvino/README.md) for instructions on running examples of various of models with openvino backend.
250+
Please refer to [README.md](../../examples/openvino/README.md) for instructions on running examples of various models with the OpenVINO backend.

0 commit comments

Comments
 (0)