@@ -76,7 +76,7 @@ BackendManager::BackendManager(SessionContext& session_context,
76
76
ptr_stream_t model_stream;
77
77
std::unique_ptr<onnx::ModelProto> model_proto;
78
78
if (subgraph_context_.is_ep_ctx_graph ) {
79
- model_stream = ep_ctx_handle_.GetModelBlobStream (subgraph);
79
+ model_stream = ep_ctx_handle_.GetModelBlobStream (session_context_. so_context_file_path , subgraph);
80
80
} else {
81
81
model_proto = GetModelProtoFromFusedNode (fused_node, subgraph, logger);
82
82
}
@@ -214,21 +214,29 @@ Status BackendManager::ExportCompiledBlobAsEPCtxNode(const onnxruntime::GraphVie
214
214
// If not embed_mode, dump the blob here and only pass on the path to the blob
215
215
std::string model_blob_str;
216
216
auto compiled_model = concrete_backend_->GetOVCompiledModel ();
217
- if (session_context_.so_context_embed_mode ) {
218
- // Internal blob
217
+ if (session_context_.so_context_embed_mode ) { // Internal blob
219
218
std::ostringstream model_blob_stream;
220
219
compiled_model.export_model (model_blob_stream);
221
220
model_blob_str = std::move (model_blob_stream).str ();
222
221
if (model_blob_str.empty ()) {
223
222
ORT_THROW (" Model blob stream is empty after exporting the compiled model." );
224
223
}
225
- } else {
226
- // External blob
224
+ } else { // External blob
225
+ // Build name by combining EpCtx model name (if available) and subgraph name. Model
226
+ // name is not available in when creating a session from memory
227
+ auto name = session_context_.so_context_file_path .stem ().string ();
228
+ if (!name.empty () && !graph_body_viewer.ModelPath ().empty ()) {
229
+ name = graph_body_viewer.ModelPath ().stem ().string ();
230
+ }
231
+ if (!name.empty ()) {
232
+ name += " _" ;
233
+ }
234
+ name += subgraph_context_.subgraph_name ;
235
+
227
236
std::filesystem::path blob_filename = session_context_.so_context_file_path ;
228
237
if (blob_filename.empty ()) {
229
238
blob_filename = session_context_.onnx_model_path_name ;
230
239
}
231
- const auto name = graph_body_viewer.ModelPath ().stem ().string () + " _" + subgraph_context_.subgraph_name ;
232
240
blob_filename = blob_filename.parent_path () / name;
233
241
blob_filename.replace_extension (" blob" );
234
242
std::ofstream blob_file (blob_filename,
0 commit comments