-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Merged
Merged
Changes from 43 commits
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
732f29a
Create IExecutionProvider wrapper for OrtEp
adrianlizarraga 9c39966
Add OrtEp::GetCapability and stub implementation in dummy ep
adrianlizarraga db2cda3
Simplify GetCapability for OrtEp (no allocator). Make OrtGraph compat…
adrianlizarraga 93900ba
Add API OrtGraph_GetNodes()
adrianlizarraga 5676355
Derive from OrtNode and OrtGraph instead of using variant (reduce str…
adrianlizarraga 353fdb8
Separate model-editor and ep-api graph types into different files
adrianlizarraga 62eb132
Revert variable name change to reduce diff
adrianlizarraga 38b5398
Add some comments
adrianlizarraga 09cea7a
Add unit test that adds the example plugin ep to a session.
adrianlizarraga a659a80
Merge branch 'main' into adrianl/ep-abi
adrianlizarraga 9f45c18
Add C APIs to get a node's name and op_type
adrianlizarraga 7cac7d1
Update error message when user passes in the wrong kind of OrtNode/Or…
adrianlizarraga 5b38f4b
Add ToInternal() methods to convert from OrtNode to its derived classes
adrianlizarraga 8abe39e
clean up
adrianlizarraga 9abc3ff
Rename AddSupportedNodes api func. Dont force eps to provide a subgra…
adrianlizarraga df0636d
Add OrtEp::Compile()
adrianlizarraga 177828a
Fill out Compile() wrapper function more
adrianlizarraga 0206de9
Fix annotation
adrianlizarraga a3ab415
Update NodeComputeInfo handling
adrianlizarraga 59b5367
Merge branch 'main' into adrianl/ep-abi
adrianlizarraga 77b3037
Finish making Mul work in example plugin EP
adrianlizarraga 1b616d8
rename file
adrianlizarraga 217aca1
Apply suggestions from code review
adrianlizarraga 2adb618
Update onnxruntime/test/autoep/library/example_plugin_ep.cc
adrianlizarraga e144c80
hide reinterpret_cast with a ToInternal call
adrianlizarraga 9031bd5
Use only one enum to differentiate between the ModelEditorApi and EpA…
adrianlizarraga 37dd688
Add many more graph apis for traversing edges
adrianlizarraga ee354a4
Move graph apis to OrtApi struct
adrianlizarraga 3a99ff2
ifdef out stuff for minimal build
adrianlizarraga d969d11
More ifdef for minimal builds
adrianlizarraga deb145d
Rename API to GetValueInfoUses to account for multiple OrtNode instan…
adrianlizarraga ac95834
Fix call to GetUses
adrianlizarraga dfc4f48
Make returning the producer's output index optional
adrianlizarraga c58ec9d
Return error status from GetValueInfoTypeInfo if type info is not valid
adrianlizarraga d7dc6db
Add a test executable for testing use of OrtGraph APIs
adrianlizarraga c1ada2f
Add nv lib to test; clean up
adrianlizarraga 4443f2e
Cleanup: add includes, update some comments
adrianlizarraga c219e56
Merge main and fix conflicts
adrianlizarraga 2cf5e59
Add fused nodes back into OrtEp::Compile()
adrianlizarraga 66f78e5
Remove 'Get' from APIs that look like field/property getters
adrianlizarraga 8641558
Add remaining OrtGraph apis to get inputs/outputs
adrianlizarraga b34b83c
Set missing optional node outputs to a null OrtValueInfo
adrianlizarraga ef49e54
Rename some GetValueInfo* apis. Add ability to specify a single suppo…
adrianlizarraga a55988d
Fix GetValueConsumers() to return a negative input index for consumer…
adrianlizarraga 66044f2
Add Node_GetSinceVersion C API
adrianlizarraga 05166d2
Add C APIs: Node_GetNumSubgraphs, Node_GetSubgraphs, Node_GetParentGraph
adrianlizarraga 55e43e0
initialize var to fix warning/error on linux. set input index to -1 f…
adrianlizarraga c1e63cd
Remove OrtHardwareDevice passing from GetCapability
adrianlizarraga bc445f9
Add C APIs: Node_GetNumImplicitInputs(), Node_GetImplicitInputs()
adrianlizarraga dd1efdb
minor clean up on comments
adrianlizarraga 89e50eb
more efficient node_index_to_ep_node map
adrianlizarraga 4282be6
Merge branch 'main' into adrianl/ep-abi
adrianlizarraga e755b84
Add C API: Graph_GetParentNode(). Split up test_ep_graph.cc into anot…
adrianlizarraga 28eec29
Add C APIs to query whether an OrtValueInfo is a graph input, a graph…
adrianlizarraga 4ca1f37
Merge branch 'main' into adrianl/ep-abi
adrianlizarraga 4348e73
Address review comments and update graph ir tests
adrianlizarraga a96fc71
Merge branch 'main' into adrianl/ep-abi
adrianlizarraga e2a5b8e
Address more review comments
adrianlizarraga a9d8956
Add C API Node_Id() and sample Kahns topological sort that uses only …
adrianlizarraga e03ec4f
Merge branch 'main' into adrianl/ep-abi
adrianlizarraga 0d36505
Split up files
adrianlizarraga c6aaf40
Address review comments: factory creation in loop, delete OrtStatus
adrianlizarraga 9d0e2ae
Delete OrtStatus in provider_policy_context.cc
adrianlizarraga 3927442
Remove intermediate variable
adrianlizarraga 410e7df
Add C APIs to get initializer OrtValues
adrianlizarraga edb3b2d
Allow getting OrtValue for initializer defined in an outer scope
adrianlizarraga 35a31a0
Remove 'order' parameter from Graph_GetNodes()
adrianlizarraga f7f4043
Merge main and fix conflicts
adrianlizarraga 4772ee8
Fix warnings as errors
adrianlizarraga be4e86c
Add new c api header (for eps) to cmakes list of headers
adrianlizarraga 3f77e03
Graph_GetNodes() directly return internal order (already sorted); Mak…
adrianlizarraga 5c4af97
Python unit test that runs simple model with EP plugin
adrianlizarraga 0011333
Update include/onnxruntime/core/session/onnxruntime_c_ep_api.h
adrianlizarraga ea41d12
Update include/onnxruntime/core/session/onnxruntime_c_ep_api.h
adrianlizarraga 52d0332
Use GraphViewer's parent node/subgraph information to get initializer…
adrianlizarraga d10335e
Address many review comments
adrianlizarraga a446ca0
Merge branch 'adrianl/ep-abi' of github.com:microsoft/onnxruntime int…
adrianlizarraga f078b93
merge main and fix conflicts
adrianlizarraga 9a993c5
Apply suggestions from code review
adrianlizarraga 079add6
Add documentation for OrtConstPointerArray API functions
adrianlizarraga 32de043
Clean up
adrianlizarraga ff85323
Apply suggestions from code review
adrianlizarraga 93c6769
Add unit test for a graph with 3 layers of nested subgraphs
adrianlizarraga e072a2d
Improve OrtArrayOfConstObjects to allow api user to create
adrianlizarraga c40baba
Clean up
adrianlizarraga 74d3b4e
Add ArrayOfConstObjects_GetConstData
adrianlizarraga bae384d
Apply suggestions from code review
adrianlizarraga 981726f
Adjust naming and description of OrtArrayOfConstObjects
adrianlizarraga 910cd5e
wording: object vs element
adrianlizarraga 5be3304
Renamed GetData -> GetMutableData, GetConstData -> GetData
adrianlizarraga e1fe569
Merge branch 'main' into adrianl/ep-abi
adrianlizarraga 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,103 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
#include "core/common/inlined_containers_fwd.h" | ||
#include "core/framework/onnxruntime_typeinfo.h" | ||
#include "core/graph/onnx_protobuf.h" | ||
|
||
#define DEFINE_ORT_GRAPH_IR_TO_EXTERNAL_INTERNAL_FUNCS(external_type, internal_type, internal_api) \ | ||
external_type* ToExternal() { return static_cast<external_type*>(this); } \ | ||
const external_type* ToExternal() const { return static_cast<const external_type*>(this); } \ | ||
static internal_type* ToInternal(external_type* e) { \ | ||
return e->graph_ir_api == (internal_api) ? static_cast<internal_type*>(e) : nullptr; \ | ||
} \ | ||
static const internal_type* ToInternal(const external_type* e) { \ | ||
return e->graph_ir_api == (internal_api) ? static_cast<const internal_type*>(e) : nullptr; \ | ||
} | ||
|
||
// The public ORT graph IR types (e.g., OrtGraph, OrtNode, etc.) have different implementations for the | ||
// ModelEditor API and EP API. This enum allows a user of the base class (e.g., OrtGraph) to determine | ||
// the API for which the derived class was created. | ||
enum class OrtGraphIrApi { | ||
kInvalid = 0, | ||
kModelEditorApi, | ||
kEpApi, | ||
}; | ||
|
||
/// <summary> | ||
/// Public type that represents an ONNX value info. | ||
/// </summary> | ||
struct OrtValueInfo { | ||
explicit OrtValueInfo(OrtGraphIrApi graph_ir_api) : graph_ir_api(graph_ir_api) {} | ||
virtual ~OrtValueInfo() = default; | ||
|
||
virtual const std::string& Name() const = 0; | ||
virtual const OrtTypeInfo* TypeInfo() const = 0; | ||
|
||
struct ProducerInfo { | ||
ProducerInfo() = default; | ||
ProducerInfo(const OrtNode* node, size_t output_index) : node(node), output_index(output_index) {} | ||
const OrtNode* node = nullptr; | ||
size_t output_index = 0; | ||
}; | ||
virtual onnxruntime::Status GetProducerInfo(ProducerInfo& producer_info) const = 0; | ||
|
||
struct UseInfo { | ||
UseInfo() = default; | ||
UseInfo(const OrtNode* node, size_t input_index) : node(node), input_index(input_index) {} | ||
const OrtNode* node = nullptr; | ||
size_t input_index = 0; | ||
}; | ||
virtual onnxruntime::Status GetUses(std::vector<UseInfo>& uses) const = 0; | ||
virtual onnxruntime::Status GetNumUses(size_t& num_consumers) const = 0; | ||
|
||
OrtGraphIrApi graph_ir_api = OrtGraphIrApi::kInvalid; | ||
}; | ||
|
||
/// <summary> | ||
/// Public type that represents an ONNX attribute. Currently, an OrtOpAttr is interchangeable with AttributeProto. | ||
/// </summary> | ||
struct OrtOpAttr { | ||
ONNX_NAMESPACE::AttributeProto attr_proto; | ||
}; | ||
|
||
/// <summary> | ||
/// Public type that represents an ONNX node. | ||
/// </summary> | ||
struct OrtNode { | ||
explicit OrtNode(OrtGraphIrApi graph_ir_api) : graph_ir_api(graph_ir_api) {} | ||
virtual ~OrtNode() = default; | ||
|
||
virtual const std::string& Name() const = 0; | ||
virtual const std::string& OpType() const = 0; | ||
virtual const std::string& Domain() const = 0; | ||
virtual size_t NumInputs() const = 0; | ||
virtual size_t NumOutputs() const = 0; | ||
virtual onnxruntime::Status GetInputs(onnxruntime::InlinedVector<const OrtValueInfo*>& inputs) const = 0; | ||
virtual onnxruntime::Status GetOutputs(onnxruntime::InlinedVector<const OrtValueInfo*>& outputs) const = 0; | ||
|
||
OrtGraphIrApi graph_ir_api = OrtGraphIrApi::kInvalid; | ||
}; | ||
|
||
/// <summary> | ||
/// Public type that represents an ONNX graph. | ||
/// </summary> | ||
struct OrtGraph { | ||
explicit OrtGraph(OrtGraphIrApi graph_ir_api) : graph_ir_api(graph_ir_api) {} | ||
virtual ~OrtGraph() = default; | ||
|
||
virtual const std::string& Name() const = 0; | ||
virtual size_t NumInputs() const = 0; | ||
virtual size_t NumOutputs() const = 0; | ||
virtual onnxruntime::Status GetInputs(onnxruntime::InlinedVector<const OrtValueInfo*>& inputs) const = 0; | ||
virtual onnxruntime::Status GetOutputs(onnxruntime::InlinedVector<const OrtValueInfo*>& outputs) const = 0; | ||
virtual size_t NumNodes() const = 0; | ||
virtual std::vector<const OrtNode*> GetNodes(int order) const = 0; | ||
|
||
OrtGraphIrApi graph_ir_api = OrtGraphIrApi::kInvalid; | ||
}; |
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.