diff --git a/backends/openvino/README.md b/backends/openvino/README.md index 5ce38ade56f..708e48bb2a5 100644 --- a/backends/openvino/README.md +++ b/backends/openvino/README.md @@ -53,12 +53,20 @@ Before you begin, ensure you have openvino installed and configured on your syst 2. Extract the release package from the archive and set the environment variables. + For Linux ```bash tar -zxf openvino_toolkit_.tgz cd openvino_toolkit_ source setupvars.sh ``` + For Windows (Powershell) + ```powershell + tar -zxf openvino_toolkit_.zip + cd openvino_toolkit_ + . ./setupvars.ps1 + ``` + ### (Optional) Build OpenVINO from Source ```bash @@ -82,23 +90,54 @@ For more information about OpenVINO build, refer to the [OpenVINO Build Instruct Follow the steps below to setup your build environment: - 1. **Create a Virtual Environment** - Create a virtual environment and activate it by executing the commands below. + For Linux ```bash python -m venv env source env/bin/activate ``` + + For Windows (Powershell) + ```powershell + python -m venv env + env/Scripts/activate + ``` + 2. **Clone ExecuTorch Repository from Github** - Clone Executorch repository by executing the command below. + - On windows, make sure to 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. ```bash git clone --recurse-submodules https://github.com/pytorch/executorch.git ``` 3. **Build ExecuTorch with OpenVINO Backend** -- 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 `/cmake-out` for quick inference testing. +- The following commands build and install ExecuTorch with the OpenVINO backend, also compiles the C++ runtime libraries and binaries into `/cmake-out` for quick inference testing. ```bash - openvino_build.sh + # cd to the root of executorch repo + cd executorch + + # Get a clean cmake-out directory + ./install_executorch.sh --clean + mkdir cmake-out + + #Configure cmake + cmake \ + -DCMAKE_INSTALL_PREFIX=cmake-out \ + -DCMAKE_BUILD_TYPE=Release \ + -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \ + -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \ + -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \ + -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \ + -DEXECUTORCH_BUILD_OPENVINO=ON \ + -DEXECUTORCH_ENABLE_LOGGING=ON \ + -DPYTHON_EXECUTABLE=python \ + -DEXECUTORCH_BUILD_EXTENSION_NAMED_DATA_MAP=ON \ + -Bcmake-out . + + # We can then build the runtime components with + cmake --build cmake-out --target install --config Release ``` + - Optionally, `openvino_build.sh` script can be used to build python package or C++ libraries/binaries seperately. **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. diff --git a/backends/openvino/runtime/OpenvinoBackend.cpp b/backends/openvino/runtime/OpenvinoBackend.cpp index bac006ce916..6c7b447e043 100644 --- a/backends/openvino/runtime/OpenvinoBackend.cpp +++ b/backends/openvino/runtime/OpenvinoBackend.cpp @@ -181,21 +181,21 @@ void OpenvinoBackend::destroy(exr::DelegateHandle* handle) const { } ov::element::Type OpenvinoBackend::convert_to_openvino_type( - exa::ScalarType scalar_type) const { + exat::ScalarType scalar_type) const { switch (scalar_type) { - case exa::ScalarType::Float: + case exat::ScalarType::Float: return ov::element::f32; - case exa::ScalarType::Half: + case exat::ScalarType::Half: return ov::element::f16; - case exa::ScalarType::Int: + case exat::ScalarType::Int: return ov::element::i32; - case exa::ScalarType::Char: + case exat::ScalarType::Char: return ov::element::i8; - case exa::ScalarType::Byte: + case exat::ScalarType::Byte: return ov::element::u8; - case exa::ScalarType::Long: + case exat::ScalarType::Long: return ov::element::i64; - case exa::ScalarType::Bool: + case exat::ScalarType::Bool: return ov::element::boolean; default: throw std::runtime_error("Unsupported scalar type"); diff --git a/backends/openvino/runtime/OpenvinoBackend.h b/backends/openvino/runtime/OpenvinoBackend.h index d84e3ba1f86..59f15551c15 100644 --- a/backends/openvino/runtime/OpenvinoBackend.h +++ b/backends/openvino/runtime/OpenvinoBackend.h @@ -18,10 +18,10 @@ #include #include +using namespace std; namespace exr = executorch::runtime; -namespace exa = executorch::aten; +namespace exat = executorch::aten; -using namespace std; namespace executorch { namespace backends { @@ -49,7 +49,7 @@ class OpenvinoBackend final : public ::exr::BackendInterface { void destroy(exr::DelegateHandle* handle) const override; private: - ov::element::Type convert_to_openvino_type(exa::ScalarType scalar_type) const; + ov::element::Type convert_to_openvino_type(exat::ScalarType scalar_type) const; }; } // namespace openvino