Skip to content

Conversation

@adrianlizarraga
Copy link
Contributor

Description

Adds Graph_GetModelPath API function.

Motivation and Context

An EP that loads an EPContext model (i.e., compiled model) needs to know the base path of the model to determine the path the EPContext node binary (if stored in a file).

Copy link
Contributor

Copilot AI left a 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 adds a new Graph_GetModelPath API function to the ORT Graph API that allows execution providers to retrieve the file path of the ONNX model. This is particularly useful for execution providers that need to load EPContext models (compiled models) and determine the path to EPContext node binaries.

Key changes:

  • Added Graph_GetModelPath function to the C API that returns the model's file path
  • Implemented the function across all graph type implementations with appropriate fallbacks
  • Added comprehensive test coverage for the new functionality

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
include/onnxruntime/core/session/onnxruntime_c_api.h Adds public API declaration with documentation
onnxruntime/core/session/ort_apis.h Adds internal API declaration
onnxruntime/core/session/onnxruntime_c_api.cc Implements the API function and adds to API table
onnxruntime/core/graph/abi_graph_types.h Adds pure virtual method to base OrtGraph class
onnxruntime/core/graph/ep_api_types.h Adds method declaration to EpGraph class
onnxruntime/core/graph/ep_api_types.cc Implements method using GraphViewer's ModelPath
onnxruntime/core/graph/model_editor_api_types.h Implements method returning empty string fallback
onnxruntime/test/ep_graph/test_ep_graph.cc Adds test verification of the new API function

@adrianlizarraga adrianlizarraga marked this pull request as ready for review July 16, 2025 18:35
Copy link
Member

@yuslepukhin yuslepukhin left a comment

Choose a reason for hiding this comment

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

🕐

jywu-msft
jywu-msft previously approved these changes Jul 22, 2025
@jywu-msft
Copy link
Member

@yuslepukhin can you review again?

@adrianlizarraga
Copy link
Contributor Author

closing and reopening to make CI rerun

@adrianlizarraga
Copy link
Contributor Author

hi @yuslepukhin, can you please review again?

@adrianlizarraga adrianlizarraga merged commit 5683a62 into main Jul 23, 2025
174 of 190 checks passed
@adrianlizarraga adrianlizarraga deleted the adrianl/EpABI_GetModelPath branch July 23, 2025 17:00
@snnn
Copy link
Member

snnn commented Jul 25, 2025

Hi there! We haven't cut the release branch for this version yet, so I'm removing the release:1.23.0 label for now to keep things tidy. Thanks so much for your contribution! We'll make sure this gets included when the release is prepared. 🤖

sanketkaleoss pushed a commit to sanketkaleoss/onnxruntime that referenced this pull request Aug 11, 2025
### Description
Adds `Graph_GetModelPath` API function.



### Motivation and Context
An EP that loads an EPContext model (i.e., compiled model) needs to know
the base path of the model to determine the path the EPContext node
binary (if stored in a file).
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.

6 participants