Skip to content

Commit 07bf632

Browse files
committed
Tweak when we use the active shared context
1 parent 7129bf7 commit 07bf632

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

onnxruntime/core/providers/openvino/backend_manager.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,16 @@ BackendManager::BackendManager(SessionContext& session_context,
5050
subgraph_context_.is_ep_ctx_ovir_encapsulated = ep_ctx_handle_.CheckEPCacheContextAttribute(subgraph,
5151
session_context_.onnx_model_path_name.filename().replace_extension("xml").string());
5252

53-
if (subgraph_context_.is_ep_ctx_graph) {
53+
if (subgraph_context_.is_ep_ctx_graph && !subgraph_context_.is_ep_ctx_ovir_encapsulated) {
5454
shared_context_ = ep_ctx_handle.GetSharedContextForEpContextSubgraph(subgraph,
55-
session_context_.GetModelPath());
56-
} else if (session_context_.so_context_enable && !session_context_.so_context_embed_mode) {
55+
session_context_.GetModelPath());
56+
} else if (session_context_.so_context_enable && session_context_.so_share_ep_contexts) {
5757
shared_context_ = shared_context_manager_.GetOrCreateActiveSharedContext(session_context_.GetOutputBinPath());
5858
} else {
59-
shared_context_ = shared_context_manager_.GetOrCreateActiveSharedContext({});
59+
// Creating a shared context to satisfy backend. It won't be used for weight sharing.
60+
// Don't make it the active share context since we don't actually want to share it.
61+
shared_context_ = shared_context_manager_.GetOrCreateSharedContext(session_context_.GetOutputBinPath());
6062
}
61-
// We always want a shared context even though we might not be sharing weights.
6263
ORT_ENFORCE(shared_context_, "Could not create a shared context.");
6364

6465
subgraph_context_.model_precision = [&](const GraphViewer& graph_viewer) {

onnxruntime/core/providers/openvino/contexts.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ struct SessionContext : ProviderInfo {
102102
if (bin_file_name.empty()) {
103103
bin_file_name = onnx_model_path_name;
104104
}
105+
if (bin_file_name.empty()) {
106+
return {};
107+
}
105108
return BinManager::GetBinPathForModel(bin_file_name);
106109
}
107110

0 commit comments

Comments
 (0)