Skip to content

[EP ABI] Utility to serialize OrtGraph to GraphProto #25292

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
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

adrianlizarraga
Copy link
Contributor

@adrianlizarraga adrianlizarraga commented Jul 5, 2025

Description

  • Provides utility functions that serialize an OrtGraph to a GraphProto or ModelProto.
  • Updates the Node_GetSubgraphs API function to also return the attribute names associated with each subgraph. This is required to determine which subgraph corresponds to a given attribute.
  • Adds Graph_GetNumOperatorSets and Graph_GetOperatorSets API functions to get the opset version for each domain.

Motivation and Context

Provide a utility to facilitate porting of existing execution providers to the new EP ABI. The utilities introduced by this PR convert an OrtGraph into an ONNX protobuf representation, which some existing EPs currently convert to their internal representation. Ideally, we would prefer a more direct conversion from a OrtGraph to the EP's internal representation, but this is a large effort. These utilities enable an incremental transition.

@adrianlizarraga adrianlizarraga requested a review from chilo-ms July 5, 2025 12:15
@adrianlizarraga adrianlizarraga marked this pull request as ready for review July 6, 2025 20:48
*
* \since Version 1.23.
*/
ORT_API2_STATUS(Graph_GetNumOperatorSets, _In_ const OrtGraph* graph, _Out_ size_t* num_operator_sets);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: "Operator set" is terminology from ONNX: https://github.com/onnx/onnx/blob/3236bf77da50c6bd365e7a3d0e79ef47acace640/onnx/onnx.proto#L888-L901

ORT also uses "domain opset versions". Not sure which is clearer.

@jywu-msft
Copy link
Member

jywu-msft commented Jul 7, 2025

Thanks @adrianlizarraga! we should discuss with @chilo-ms where the utility functions should live. there are several options.

chilo-ms
chilo-ms previously approved these changes Jul 7, 2025
@adrianlizarraga
Copy link
Contributor Author

@chilo-ms @jywu-msft , I made this a header-only file that can be copied into a project that builds with ORT + ONNX. I moved it into include/onnxruntime/core/providers/utils/ort_graph_to_proto.h and added documentation comments describing how to include the file.

Please let me know if you have any feedback. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants