@@ -102,12 +102,13 @@ common::Status OpenVINOExecutionProvider::Compile(
102
102
graph_body_viewer_0.DomainToVersionMap ().at (kOnnxDomain );
103
103
}
104
104
105
+ const auto metadata_path = session_context_.GetEpContextOutputDirectory () / " metadata.bin" ;
106
+
105
107
// Temporary code to read metadata before it moves to the .bin
106
108
auto & metadata = shared_context_->shared_weights .metadata ;
107
109
if (session_context_.so_share_ep_contexts && metadata.empty ()) {
108
110
// Metadata is always read from model location, this could be a source or epctx model
109
- fs::path metadata_filename = session_context_.onnx_model_path_name .parent_path () / " metadata.bin" ;
110
- std::ifstream file (metadata_filename, std::ios::binary);
111
+ std::ifstream file (metadata_path, std::ios::binary);
111
112
if (file) {
112
113
file >> metadata;
113
114
}
@@ -174,18 +175,13 @@ common::Status OpenVINOExecutionProvider::Compile(
174
175
}
175
176
176
177
if (session_context_.so_share_ep_contexts ) {
177
- fs::path metadata_filename;
178
- if (session_context_.so_context_file_path .empty ()) {
179
- metadata_filename = session_context_.onnx_model_path_name .parent_path () / " metadata.bin" ;
180
- } else {
181
- metadata_filename = session_context_.so_context_file_path .parent_path () / " metadata.bin" ;
182
- }
178
+ const auto & sw_path_filename = shared_context_->shared_weights .external_weight_filename ;
179
+ fs::path new_weights_file_path = session_context_.GetNewWeightsFilePath (sw_path_filename);
180
+ fs::path original_weights_path = session_context_.GetModelDirectory () / sw_path_filename;
181
+
182
+ std::filesystem::copy_file (original_weights_path, new_weights_file_path, std::filesystem::copy_options::skip_existing);
183
183
184
- // Metadata is generated only for shared contexts
185
- // If saving metadata then save it to the provided path or ose the original model path
186
- // Multiple calls to Compile() will update the metadata and for the last call
187
- // the resulting file will contain the aggregated content
188
- std::ofstream file (metadata_filename, std::ios::binary);
184
+ std::ofstream file (metadata_path, std::ios::binary);
189
185
if (file) {
190
186
file << metadata;
191
187
}
0 commit comments