-
Notifications
You must be signed in to change notification settings - Fork 883
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
Open
shoumikhin
wants to merge
1
commit into
pytorch:main
Choose a base branch
from
shoumikhin:export-D97202714
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.