@@ -47,7 +47,6 @@ void printDebugInfo(const ov::CompiledModel& obj) {
47
47
continue ;
48
48
OPENVINO_SUPPRESS_DEPRECATED_END
49
49
std::cout << " " << item2.first << " : " << item2.second .as <std::string>() << std::endl;
50
- }
51
50
}
52
51
} else {
53
52
std::cout << " " << cfg << " : " << prop.as <std::string>() << std::endl;
@@ -101,10 +100,10 @@ OVExeNetwork OVCore::StatefulCompileModel(std::shared_ptr<OVNetwork>& model,
101
100
LogBasicModelInfo (model);
102
101
}
103
102
104
- LOGS_DEFAULT (INFO) << log_tag << " Converting from Stateless OV Model to Stateful OV Model" << std::endl;
105
103
bool model_status = IsStateful (model);
106
104
LOGS_DEFAULT (INFO) << log_tag << " Model IsStateful() Status:\t " << (model_status ? " True" : " False" );
107
105
if (!model_status) {
106
+ LOGS_DEFAULT (INFO) << log_tag << " Converting from Stateless OV Model to Stateful OV Model" << std::endl;
108
107
PatchStatefulDecoder (model);
109
108
}
110
109
@@ -198,15 +197,69 @@ OVExeNetwork OVCore::ImportModel(std::istream& model_stream,
198
197
return OvExceptionBoundary ([&]() {
199
198
ov::CompiledModel obj;
200
199
obj = core.import_model (model_stream, hw_target, device_config);
200
+ OVExeNetwork exe (obj, hw_target);
201
201
#ifndef NDEBUG
202
202
printDebugInfo (exe.Get ());
203
203
#endif
204
- OVExeNetwork exe (obj, hw_target);
205
204
return exe;
206
205
},
207
206
" Exception while Loading Network for graph {}" , name);
208
207
}
209
208
209
+ OVExeNetwork OVCore::ImportEPCtxOVIREncapsulation (std::istream& model_stream,
210
+ std::string& hw_target,
211
+ const ov::AnyMap& device_config,
212
+ bool enable_causallm,
213
+ std::filesystem::path model_file_path) {
214
+ return OvExceptionBoundary ([&]() {
215
+ OVExeNetwork exe;
216
+
217
+ bool isXML = backend_utils::IsModelStreamXML (model_stream);
218
+
219
+ // Helper function to check if file exists and is readable
220
+ const auto check_file_access = [&model_file_path](const std::filesystem::path& path) {
221
+ try {
222
+ if (!std::filesystem::exists (path) || std::filesystem::is_empty (path)) {
223
+ ORT_THROW (log_tag + " Required file missing or empty: " + path.string ());
224
+ }
225
+ std::ifstream file (path);
226
+ if (!file) {
227
+ ORT_THROW (log_tag + " Required file not readable: " + path.string ());
228
+ }
229
+ } catch (const std::exception& e) {
230
+ ORT_THROW (log_tag + " Exception while checking file access for: " + path.string () + " - " + e.what ());
231
+ }
232
+ };
233
+
234
+ if (isXML) {
235
+ // If the model is XML, we need to load it with the XML content in read_model()
236
+ // where weights from bin file is directly consumed
237
+ auto xml_file_path = model_file_path.parent_path () / (model_file_path.stem ().string () + " .xml" );
238
+
239
+ check_file_access (xml_file_path);
240
+
241
+ LOGS_DEFAULT (INFO) << log_tag << " Reading OVIR from XML file path: " << xml_file_path.string ();
242
+
243
+ // Load the model explicitly with XML contents
244
+ std::shared_ptr<ov::Model> model = core.read_model (xml_file_path.string ());
245
+
246
+ if (enable_causallm) {
247
+ exe = OVCore::Get ()->StatefulCompileModel (model, hw_target, device_config);
248
+ } else {
249
+ auto obj = core.compile_model (model, hw_target, device_config);
250
+ exe = OVExeNetwork (obj, hw_target);
251
+ }
252
+ }
253
+
254
+ #ifndef NDEBUG
255
+ printDebugInfo (exe.Get ());
256
+ #endif
257
+ return exe;
258
+ },
259
+ " Exception while Loading Network from OVIR model file: {}" , model_file_path.string ());
260
+ }
261
+
262
+
210
263
void OVCore::SetCache (const std::string& cache_dir_path) {
211
264
core.set_property (ov::cache_dir (cache_dir_path));
212
265
}
0 commit comments