diff --git a/onnxruntime/core/providers/openvino/backends/basic_backend.cc b/onnxruntime/core/providers/openvino/backends/basic_backend.cc index a88de64456..55539254f5 100644 --- a/onnxruntime/core/providers/openvino/backends/basic_backend.cc +++ b/onnxruntime/core/providers/openvino/backends/basic_backend.cc @@ -90,11 +90,11 @@ BasicBackend::BasicBackend(const ONNX_NAMESPACE::ModelProto& model_proto, device_config, subgraph_context_.subgraph_name); ie_cnn_network_ = exe_network_.Get().get_runtime_model(); - } else if (!subgraph_context_.has_dynamic_input_shape && - global_context_.onnx_model_path_name.find(".onnx") != std::string ::npos) { + } else if (!subgraph_context_.has_dynamic_input_shape) { // Inputs with static dimenstions std::string prec_str = (global_context_.precision_str != "ACCURACY") ? global_context_.precision_str : global_context_.model_precision; - exe_network_ = global_context_.ie_core.CompileModel(global_context_.onnx_model_path_name, + const std::string model = model_proto.SerializeAsString(); + exe_network_ = global_context_.ie_core.CompileModel(model, hw_target, prec_str, global_context_.cache_dir, diff --git a/onnxruntime/core/providers/openvino/ov_interface.cc b/onnxruntime/core/providers/openvino/ov_interface.cc index 948bd480b4..e06cf12664 100644 --- a/onnxruntime/core/providers/openvino/ov_interface.cc +++ b/onnxruntime/core/providers/openvino/ov_interface.cc @@ -88,7 +88,7 @@ OVExeNetwork OVCore::CompileModel(std::shared_ptr& ie_cnn_netwo } } -OVExeNetwork OVCore::CompileModel(const std::string onnx_model_path, +OVExeNetwork OVCore::CompileModel(const std::string& onnx_model, std::string& hw_target, std::string precision, std::string cache_dir, @@ -97,13 +97,13 @@ OVExeNetwork OVCore::CompileModel(const std::string onnx_model_path, ov::CompiledModel obj; try { if (hw_target == "AUTO:GPU,CPU") { - obj = oe.compile_model(onnx_model_path, + obj = oe.compile_model(onnx_model, ov::Tensor(), "AUTO", ov::device::priorities("GPU", "CPU"), ov::device::properties("GPU", {ov::cache_dir(cache_dir), ov::hint::inference_precision(precision)})); } else { - obj = oe.compile_model(onnx_model_path, hw_target, device_config); + obj = oe.compile_model(onnx_model, ov::Tensor(), hw_target, device_config); } #ifndef NDEBUG printDebugInfo(obj); diff --git a/onnxruntime/core/providers/openvino/ov_interface.h b/onnxruntime/core/providers/openvino/ov_interface.h index 07b47d2158..de6877a15b 100644 --- a/onnxruntime/core/providers/openvino/ov_interface.h +++ b/onnxruntime/core/providers/openvino/ov_interface.h @@ -44,7 +44,7 @@ class OVCore { std::string& hw_target, ov::AnyMap& device_config, std::string name); - OVExeNetwork CompileModel(const std::string onnx_model_path, + OVExeNetwork CompileModel(const std::string& onnx_model, std::string& hw_target, std::string precision, std::string cache_dir,