-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add GetCapability/Compile infrastructure for EP ABI #24887
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
Conversation
…ible with OrtEpApi.
…uct sizes for ep api)
…tGraph to the model editor api
…ph/capability name
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.
Pull Request Overview
This PR lays the groundwork for a binary-stable plugin EP ABI in ORT, adds a sample plugin EP that runs a single Mul
operator, and extends the core/session stack and C APIs to load and invoke plugin EPs.
- Introduce
example_plugin_ep.cc
showing how a plugin-EP implementsOrtEp
and node compute callbacks. - Extend the C API (
onnxruntime_c_api.h
,ep_api.h/cc
) and internal types (abi_ep_types.h
,ep_plugin_provider_interfaces.*
) to support graph/node enumeration andOrtNodeComputeInfo
. - Update session creation and partitioner code (
utils.cc
,provider_policy_context.cc
,graph_partitioner.cc
, etc.) to recognize and wrap plugin EPs.
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
test/autoep/library/example_plugin_ep.cc | Sample EP implementation with MulKernel and EP API usage. |
include/onnxruntime/core/session/onnxruntime_c_api.h | Add OrtNodeComputeInfo and NodeComputeContext_NodeName . |
core/session/ep_api.h / ep_api.cc | Implement Graph_Get* , Node_Get* , and EpGraphSupportInfo_AddSupportedNodes . |
core/session/ep_plugin_provider_interfaces.* | Define PluginExecutionProviderFactory and PluginExecutionProvider . |
core/session/utils.cc | Construct plugin vs. internal EP factory based on devices. |
core/session/provider_policy_context.cc | Invoke CreateEp instead of ORT_NOT_IMPLEMENTED . |
core/session/ep_factory_internal.* | Change constructor signatures to use gsl::span . |
core/graph/model_editor_api_types.* / model_editor_c_api.cc | Add internal/external conversion and null checks. |
core/graph/graph.cc | Adapt LoadFromModelEditorApiModel to new ModelEditorGraph . |
core/framework/graph_partitioner.cc | Update PlaceNode to accept ComputeCapability and handle subgraphs. |
core/framework/compute_capability.h | Add use_subgraph_name_as_fused_node_name flag. |
Comments suppressed due to low confidence (2)
onnxruntime/test/autoep/library/example_plugin_ep.cc:115
- [nitpick] The variable name
type_shape0
is ambiguous. Consider renaming totype_shape_info_input0
(and similarly fortype_shape1
) for clarity.
OrtTensorTypeAndShapeInfo* type_shape0 = nullptr;
onnxruntime/core/framework/graph_partitioner.cc:366
- The code now takes a ComputeCapability but still refers to
capability.sub_graph
, which no longer exists on that type. You need to either restore theIndexedSubGraph
parameter or update the logic to use the correct subgraph member fromComputeCapability
.
if (nullptr == capability.sub_graph->GetMetaDef()) {
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
started reviewing
Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com>
### Description Missed a few documentation errors in the [previous PR](#24887). This PR fixes the C/C++ API documentation generation action: https://github.com/microsoft/onnxruntime/actions/runs/15749541590 ### Motivation and Context Fix the C/C++ API documentation generation GitHub action.
This PRs adds additional Node_GetAttributes C API for EP ABI use. It's based on #24887
Runtime C API. PR microsoft#24887 allows plugin-EPs to interface with ORT using a binary stable interface. It is an important feature for a plugin EP to generate an EP context model as specified by https://onnxruntime.ai/docs/execution-providers/EP-Context-Design.html The EP needs to read and write the `ep_cache_context` attribute of type `ORT_OP_ATTR_STRING` as specified by https://github.com/microsoft/onnxruntime/blob/5fdd4e4f2a2b6705a9a49a378a3b3496805067ee/onnxruntime/core/graph/contrib_ops/contrib_defs.cc#L3301-L3305 The current implemention of `ReadOpAttr` regards an attribute of type `ORT_OP_ATTR_STRING` as a null terminated string. https://github.com/microsoft/onnxruntime/blob/5fdd4e4f2a2b6705a9a49a378a3b3496805067ee/onnxruntime/core/session/custom_ops.cc#L437 It is very common that `ep_cache_context` is a sequence of bytes, as specificed by ONNX https://github.com/ankane/onnxruntime-1/blob/95843a5dbc3100062be88bcb0d06fd36877f3f77/onnxruntime/core/protobuf/onnx-ml.proto#L148 This commit adds a new operator attribute type `ORT_OP_ATTR_BYTES` to the ONNX Runtime C API, which allows plugin EPs to read and write `ep_cache_context` as a sequence of bytes.
### Description Add a new ORT API `GetSessionOptionConfigEntries`. ### Motivation and Context #24887 allows plugin-EPs to interface with ORT using a binary stable interface. #24445 allows an EP to handle the extraction of EP options from the session option configurations. For an EP like VitisAI EP to comply with the requirements, it is necessary for a plugin-EPs to access all config entries in a session option. ```c++ OrtKeyValuePairs * kvps = nullptr; auto status = GetSessionOptionConfigEntries(session_option, &kvps); if(status) { throw status; } std::unique_ptr<OrtKeyValuePairs, void (*)(OrtKeyValuePairs*)> config_entries(kvps, ort_api.ReleaseKeyValuePairs); const char* const* keys = nullptr; const char* const* values = nullptr; size_t num_keys = 0; // Get keys and values from the config entries Ort::GetApi().GetKeyValuePairs(config_entries.get(), &keys, &values, &num_keys); for (size_t i = 0; i < num_keys; ++i) { // process keys[i] and values[i] } ```
Runtime C API. PR microsoft#24887 allows plugin-EPs to interface with ORT using a binary stable interface. It is an important feature for a plugin EP to generate an EP context model as specified by https://onnxruntime.ai/docs/execution-providers/EP-Context-Design.html The EP needs to read and write the `ep_cache_context` attribute of type `ORT_OP_ATTR_STRING` as specified by https://github.com/microsoft/onnxruntime/blob/5fdd4e4f2a2b6705a9a49a378a3b3496805067ee/onnxruntime/core/graph/contrib_ops/contrib_defs.cc#L3301-L3305 The current implemention of `ReadOpAttr` regards an attribute of type `ORT_OP_ATTR_STRING` as a null terminated string. https://github.com/microsoft/onnxruntime/blob/5fdd4e4f2a2b6705a9a49a378a3b3496805067ee/onnxruntime/core/session/custom_ops.cc#L437 It is very common that `ep_cache_context` is a sequence of bytes, as specificed by ONNX https://github.com/ankane/onnxruntime-1/blob/95843a5dbc3100062be88bcb0d06fd36877f3f77/onnxruntime/core/protobuf/onnx-ml.proto#L148 This commit adds a new operator attribute type `ORT_OP_ATTR_BYTES` to the ONNX Runtime C API, which allows plugin EPs to read and write `ep_cache_context` as a sequence of bytes.
### Description Add a new ORT API `GetSessionOptionConfigEntries`. ### Motivation and Context microsoft#24887 allows plugin-EPs to interface with ORT using a binary stable interface. microsoft#24445 allows an EP to handle the extraction of EP options from the session option configurations. For an EP like VitisAI EP to comply with the requirements, it is necessary for a plugin-EPs to access all config entries in a session option. ```c++ OrtKeyValuePairs * kvps = nullptr; auto status = GetSessionOptionConfigEntries(session_option, &kvps); if(status) { throw status; } std::unique_ptr<OrtKeyValuePairs, void (*)(OrtKeyValuePairs*)> config_entries(kvps, ort_api.ReleaseKeyValuePairs); const char* const* keys = nullptr; const char* const* values = nullptr; size_t num_keys = 0; // Get keys and values from the config entries Ort::GetApi().GetKeyValuePairs(config_entries.get(), &keys, &values, &num_keys); for (size_t i = 0; i < num_keys; ++i) { // process keys[i] and values[i] } ```
Description
This PRs sets the foundation for the EP ABI, which allows plugin-EPs to interface with ORT using a binary stable interface. A plugin-EP can be built separately from ORT and is not tied to a specific commit of ORT.
Currently, this PR adds basic APIs necessary to allow an example plugin-EP to compile and run a simple model with a single
Mul
node.Motivation and Context
Based on #21450