Handle EP context paths with external initializers - #32709
FranciscoMaxwell wants to merge 1 commit into
Conversation
|
FranciscoMaxwell please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
1 similar comment
|
FranciscoMaxwell please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Session initialization currently invokes a throwing copy-assignment operator, and nested EPContext nodes are not detected.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Defaults EP context paths when external initializers override model lookup.
Changes:
- Detects EPContext nodes during file-path model loading.
- Passes loaded session options to provider factories.
- Updates OpenVINO validation and guidance.
| File | Description |
|---|---|
inference_session.cc |
Derives EP context paths during load. |
utils.cc |
Propagates loaded options to providers. |
onnx_ctx_model_helper.cc |
Updates OpenVINO guidance. |
onnxruntime_session_options_config_keys.h |
Clarifies option documentation. |
openvino_ep_context_test.cc |
Tests implicit path resolution. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const OrtSessionOptions* effective_options = options; | ||
| OrtSessionOptions options_with_session_options; | ||
| if (options != nullptr) { | ||
| options_with_session_options = *options; | ||
| options_with_session_options.value = sess.GetSessionOptions(); | ||
| effective_options = &options_with_session_options; | ||
| } |
| bool HasEpContextNode(const Model& model) { | ||
| for (const auto& node : model.MainGraph().Nodes()) { | ||
| if (node.OpType() == "EPContext" && node.Domain() == kMSDomain) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } |


Description
ep.context_file_pathto the file-path EPContext model whensession.model_external_initializers_file_folder_pathis also set and the loaded model contains EPContext nodes.Load().ep.context_file_path.Motivation and Context
Fixes #32054.
When file-path EPContext models are loaded with
session.model_external_initializers_file_folder_path, ORT changes the graph model path used for external initializer lookup to a virtual path in the initializer folder. OpenVINO also uses the graph model path to resolve a relative external EP context binary, so it ends up looking forctx_OpenVINOExecutionProvider.binin the external initializer folder instead of next toctx.onnx.For file-path loads, ORT still knows the actual EPContext model path. This change preserves that path in
ep.context_file_pathonly for loaded EPContext models when the user did not already set it.Testing
git diff --checkonnxruntime_config.h; full ONNX Runtime CI should build the affected targets.