diff --git a/onnxruntime/core/providers/openvino/onnx_ctx_model_helper.cc b/onnxruntime/core/providers/openvino/onnx_ctx_model_helper.cc index 8f47155d34fa1..60a461f7159f3 100644 --- a/onnxruntime/core/providers/openvino/onnx_ctx_model_helper.cc +++ b/onnxruntime/core/providers/openvino/onnx_ctx_model_helper.cc @@ -253,9 +253,14 @@ std::shared_ptr EPCtxHandler::Initialize(const std::vectorGetOrCreateActiveSharedContext(session_context.GetOutputBinPath()); + if (session_context.so_context_enable && session_context.so_share_ep_contexts) { + // We're creating a shared ep context model get or create the active context. + shared_context = shared_context_manager_->GetOrCreateActiveSharedContext(session_context.GetOutputBinPath()); + } else { + shared_context = shared_context_manager_->GetOrCreateSharedContext(session_context.GetOutputBinPath()); + } } return shared_context;