-
Notifications
You must be signed in to change notification settings - Fork 884
Add OpenVINO backend to pip wheel for Linux x86_64 (#18309) #18309
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,10 @@ to run ExecuTorch `.pte` files, with some restrictions: | |
| * Only the [XNNPACK backend delegate](docs/source/backends/xnnpack/xnnpack-overview.md) is linked into the prebuilt module. | ||
| * \[macOS only] [Core ML](docs/source/backends/coreml/coreml-overview.md) and [MPS](docs/source/backends/mps/mps-overview.md) backend | ||
| are also linked into the prebuilt module. | ||
| * \[Linux x86_64] [QNN](docs/source/backends-qualcomm.md) backend is linked into the prebuilt module. | ||
| * \[Linux] [OpenVINO](docs/source/build-run-openvino.md) backend is also linked into the | ||
| prebuilt module. OpenVINO requires the runtime to be installed separately: | ||
| `pip install executorch[openvino]` | ||
|
Comment on lines
+17
to
+20
|
||
|
|
||
| Please visit the [ExecuTorch website](https://pytorch.org/executorch) for | ||
| tutorials and documentation. Here are some starting points: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <dlfcn.h> | ||
| #include <cstddef> | ||
| #include <cstdint> | ||
| #include <memory> | ||
|
|
||
| namespace executorch { | ||
| namespace backends { | ||
| namespace openvino { | ||
|
|
||
| // Forward declarations matching the OpenVINO C API opaque types. | ||
| // Only pointer types are used so struct layout is irrelevant. | ||
| typedef struct ov_core ov_core_t; | ||
| typedef struct ov_compiled_model ov_compiled_model_t; | ||
| typedef struct ov_infer_request ov_infer_request_t; | ||
| typedef struct ov_tensor ov_tensor_t; | ||
|
|
||
| // Value types reproduced from openvino/c/ov_shape.h and ov_common.h. | ||
| // These are stable C ABI — pinned via version constraint in pyproject.toml. | ||
| typedef struct { | ||
| int64_t rank; | ||
| int64_t* dims; | ||
| } ov_shape_t; | ||
|
|
||
| typedef struct { | ||
| char** devices; | ||
| size_t size; | ||
| } ov_available_devices_t; | ||
|
|
||
shoumikhin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Intentionally partial — only OV_STATUS_OK is needed for success checks. | ||
| // The full enum is defined in openvino/c/ov_common.h. | ||
| typedef enum { | ||
| OV_STATUS_OK = 0, | ||
| OV_STATUS_GENERAL_ERROR = -1, | ||
| } ov_status_e; | ||
|
|
||
| // Values aligned with ov::element::Type_t (sequential enum). | ||
| typedef enum { | ||
| OV_ELEMENT_UNDEFINED = 0, | ||
| OV_ELEMENT_BOOLEAN = 1, | ||
| OV_ELEMENT_BF16 = 2, | ||
| OV_ELEMENT_F16 = 3, | ||
| OV_ELEMENT_F32 = 4, | ||
| OV_ELEMENT_F64 = 5, | ||
| OV_ELEMENT_I4 = 6, | ||
| OV_ELEMENT_I8 = 7, | ||
| OV_ELEMENT_I16 = 8, | ||
| OV_ELEMENT_I32 = 9, | ||
| OV_ELEMENT_I64 = 10, | ||
| OV_ELEMENT_U1 = 11, | ||
| OV_ELEMENT_U2 = 12, | ||
| OV_ELEMENT_U3 = 13, | ||
| OV_ELEMENT_U4 = 14, | ||
| OV_ELEMENT_U6 = 15, | ||
| OV_ELEMENT_U8 = 16, | ||
| } ov_element_type_e; | ||
|
|
||
| // Function pointer types for each OpenVINO C API function we use. | ||
| using ov_core_create_fn = ov_status_e (*)(ov_core_t**); | ||
| using ov_core_free_fn = void (*)(ov_core_t*); | ||
| using ov_core_get_available_devices_fn = | ||
| ov_status_e (*)(const ov_core_t*, ov_available_devices_t*); | ||
| using ov_available_devices_free_fn = void (*)(ov_available_devices_t*); | ||
| using ov_core_import_model_fn = ov_status_e (*)( | ||
| const ov_core_t*, | ||
| const char*, | ||
| size_t, | ||
| const char*, | ||
| ov_compiled_model_t**); | ||
| using ov_compiled_model_create_infer_request_fn = | ||
| ov_status_e (*)(const ov_compiled_model_t*, ov_infer_request_t**); | ||
| using ov_compiled_model_inputs_size_fn = | ||
| ov_status_e (*)(const ov_compiled_model_t*, size_t*); | ||
| using ov_compiled_model_outputs_size_fn = | ||
| ov_status_e (*)(const ov_compiled_model_t*, size_t*); | ||
| using ov_compiled_model_free_fn = void (*)(ov_compiled_model_t*); | ||
| using ov_infer_request_set_input_tensor_by_index_fn = | ||
| ov_status_e (*)(ov_infer_request_t*, size_t, const ov_tensor_t*); | ||
| using ov_infer_request_set_output_tensor_by_index_fn = | ||
| ov_status_e (*)(ov_infer_request_t*, size_t, const ov_tensor_t*); | ||
| using ov_infer_request_infer_fn = ov_status_e (*)(ov_infer_request_t*); | ||
| using ov_infer_request_free_fn = void (*)(ov_infer_request_t*); | ||
| using ov_tensor_create_from_host_ptr_fn = | ||
| ov_status_e (*)(ov_element_type_e, ov_shape_t, void*, ov_tensor_t**); | ||
| using ov_tensor_free_fn = void (*)(ov_tensor_t*); | ||
| using ov_shape_create_fn = | ||
| ov_status_e (*)(int64_t, const int64_t*, ov_shape_t*); | ||
| using ov_shape_free_fn = ov_status_e (*)(ov_shape_t*); | ||
|
|
||
| struct DlCloser { | ||
| void operator()(void* handle) { | ||
| if (handle) { | ||
| dlclose(handle); | ||
| } | ||
| } | ||
| }; | ||
| using DlHandle = std::unique_ptr<void, DlCloser>; | ||
|
|
||
| struct OpenvinoFunctions { | ||
| ov_core_create_fn core_create = nullptr; | ||
| ov_core_free_fn core_free = nullptr; | ||
| ov_core_get_available_devices_fn core_get_available_devices = nullptr; | ||
| ov_available_devices_free_fn available_devices_free = nullptr; | ||
| ov_core_import_model_fn core_import_model = nullptr; | ||
| ov_compiled_model_create_infer_request_fn | ||
| compiled_model_create_infer_request = nullptr; | ||
| ov_compiled_model_inputs_size_fn compiled_model_inputs_size = nullptr; | ||
| ov_compiled_model_outputs_size_fn compiled_model_outputs_size = nullptr; | ||
| ov_compiled_model_free_fn compiled_model_free = nullptr; | ||
| ov_infer_request_set_input_tensor_by_index_fn | ||
| infer_request_set_input_tensor_by_index = nullptr; | ||
| ov_infer_request_set_output_tensor_by_index_fn | ||
| infer_request_set_output_tensor_by_index = nullptr; | ||
| ov_infer_request_infer_fn infer_request_infer = nullptr; | ||
| ov_infer_request_free_fn infer_request_free = nullptr; | ||
| ov_tensor_create_from_host_ptr_fn tensor_create_from_host_ptr = nullptr; | ||
| ov_tensor_free_fn tensor_free = nullptr; | ||
| ov_shape_create_fn shape_create = nullptr; | ||
| ov_shape_free_fn shape_free = nullptr; | ||
| }; | ||
|
|
||
| } // namespace openvino | ||
| } // namespace backends | ||
| } // namespace executorch | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This installs
openvinoon all Linux wheel builds, including the linux-aarch64 workflow that also uses this pre-script. Since the aarch64 smoke test only checks backend registration (no runtime load), consider gating this install to x86_64 (or making it best-effort/optional) to avoid unnecessary CI time and potential platform-specific install failures.