@@ -84,18 +84,21 @@ BackendManager::BackendManager(SessionContext& session_context,
84
84
std::string device_type = session_context_.device_type ;
85
85
86
86
auto & sw = shared_context_.shared_weights ;
87
+ if (sw.external_weight_filename .empty () && !sw.metadata .empty ()) {
88
+ // Reasonable assumption that all metadata entries have the same external file location
89
+ sw.external_weight_filename = sw.metadata .begin ()->second .location ;
90
+ }
91
+
87
92
if (session_context_.so_share_ep_contexts ) {
88
- std::filesystem::path weight_filename = session_context_.onnx_model_path_name .parent_path ();
89
- if (sw.external_weight_filename .empty () && !sw.metadata .empty ()) {
90
- // Reasonable assumption that all metadata entries have the same external file location
91
- sw.external_weight_filename = sw.metadata .begin ()->second .location ;
93
+ auto weight_path = session_context_.GetNewWeightsFilePath (sw.external_weight_filename );
94
+ if (!std::filesystem::exists (weight_path)) {
95
+ weight_path = session_context_.GetModelDirectory () / sw.external_weight_filename ;
92
96
}
93
- weight_filename /= sw.external_weight_filename ;
94
- std::ifstream weight_file (weight_filename);
95
97
98
+ std::ifstream weight_file (weight_path);
96
99
if (weight_file) {
97
100
if (!sw.mapped_weights ) {
98
- sw.mapped_weights = std::make_unique<SharedContext::SharedWeights::WeightsFile>(weight_filename );
101
+ sw.mapped_weights = std::make_unique<SharedContext::SharedWeights::WeightsFile>(weight_path );
99
102
}
100
103
backend_utils::CreateOVTensors (session_context_.device_type , sw.metadata , *sw.mapped_weights );
101
104
}
@@ -241,7 +244,7 @@ Status BackendManager::ExportCompiledBlobAsEPCtxNode(const onnxruntime::GraphVie
241
244
std::ofstream blob_file (blob_filename,
242
245
std::ios::out | std::ios::trunc | std::ios::binary);
243
246
if (!blob_file) {
244
- ORT_THROW (" Unable to open file for epctx model dump." );
247
+ ORT_THROW (" Unable to open file for epctx model dump." + blob_filename. string () );
245
248
}
246
249
compiled_model.export_model (blob_file);
247
250
model_blob_str = blob_filename.filename ().string ();
@@ -324,7 +327,7 @@ static bool IsQDQGraph(const onnxruntime::GraphViewer& graph_viewer) {
324
327
static void DumpOpenVINOEPModel ([[maybe_unused]] const std::filesystem::path& onnx_model_path_name,
325
328
[[maybe_unused]] ONNX_NAMESPACE::ModelProto* model_proto,
326
329
[[maybe_unused]] const onnxruntime::Node& fused_node) {
327
- #ifdef NOT_RELEASE
330
+ #ifdef NOT_RELEASE
328
331
if (openvino_ep::backend_utils::IsDebugEnabled ()) {
329
332
auto model_name = onnx_model_path_name.empty () ? " unknown.onnx" : onnx_model_path_name.filename ();
330
333
0 commit comments