Skip to content

Commit

Permalink
Ovep 1.17.1 (#19482)
Browse files Browse the repository at this point in the history
### Description
Handle  bugs for API backward compatability.
Update to consume the onnx model path rather the onnx serialised model
to OV compile_model API
  • Loading branch information
preetha-intel committed Feb 12, 2024
1 parent 9cb97ee commit 90e2e85
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
11 changes: 7 additions & 4 deletions onnxruntime/core/providers/openvino/backends/basic_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ BasicBackend::BasicBackend(const ONNX_NAMESPACE::ModelProto& model_proto,
LOGS_DEFAULT(INFO) << log_tag << "Loaded model to the plugin";
}
#else
if (global_context_.disable_dynamic_shapes && dev_prec != "CPU_FP16") {
const std::string model = model_proto.SerializeAsString();
exe_network_ = global_context_.ie_core.LoadNetwork(
model, hw_target, device_config, subgraph_context_.subgraph_name);
if (!subgraph_context_.has_dynamic_input_shape &&
global_context_.onnx_model_path_name != "" &&
dev_prec != "CPU_FP16") {
exe_network_ = global_context_.ie_core.LoadNetwork(global_context_.onnx_model_path_name,
hw_target,
device_config,
subgraph_context_.subgraph_name);
LOGS_DEFAULT(INFO) << log_tag << "Loaded model to the plugin";
} else {
ie_cnn_network_ = CreateOVModel(model_proto, global_context_, subgraph_context_, const_outputs_map_);
Expand Down
4 changes: 2 additions & 2 deletions onnxruntime/core/providers/openvino/ov_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ OVExeNetwork OVCore::LoadNetwork(std::shared_ptr<OVNetwork>& ie_cnn_network,
}
}

OVExeNetwork OVCore::LoadNetwork(const std::string& model,
OVExeNetwork OVCore::LoadNetwork(const std::string onnx_model_path,
std::string& hw_target,
ov::AnyMap& device_config,
std::string name) {
ov::CompiledModel obj;
try {
obj = oe.compile_model(model, ov::Tensor(), hw_target, device_config);
obj = oe.compile_model(onnx_model_path, hw_target, device_config);
OVExeNetwork exe(obj);
return exe;
} catch (const Exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/providers/openvino/ov_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class OVCore {
std::string& hw_target,
ov::AnyMap& device_config,
std::string name);
OVExeNetwork LoadNetwork(const std::string& model_stream,
OVExeNetwork LoadNetwork(const std::string model_path,
std::string& hw_target,
ov::AnyMap& device_config,
std::string name);
Expand Down
18 changes: 10 additions & 8 deletions onnxruntime/core/session/provider_bridge_ort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,11 @@ ProviderOptions OrtOpenVINOProviderOptionsToOrtOpenVINOProviderOptionsV2(const O
if (legacy_ov_options->device_type != nullptr)
ov_options_converted_map["device_type"] = legacy_ov_options->device_type;

ov_options_converted_map["enable_npu_fast_compile"] = legacy_ov_options->enable_npu_fast_compile;
if (legacy_ov_options->enable_npu_fast_compile) {
ov_options_converted_map["enable_npu_fast_compile"] = "false";
} else {
ov_options_converted_map["enable_npu_fast_compile"] = "true";
}

if (legacy_ov_options->device_id != nullptr)
ov_options_converted_map["device_id"] = legacy_ov_options->device_id;
Expand All @@ -1701,14 +1705,12 @@ ProviderOptions OrtOpenVINOProviderOptionsToOrtOpenVINOProviderOptionsV2(const O

ov_options_converted_map["enable_opencl_throttling"] = legacy_ov_options->enable_opencl_throttling;

if (legacy_ov_options->enable_dynamic_shapes != '\0') {
std::string enable_dynamic_shapes = reinterpret_cast<const char*>(legacy_ov_options->enable_dynamic_shapes);
if (enable_dynamic_shapes == "true" || enable_dynamic_shapes == "True") {
ov_options_converted_map["disable_dynamic_shapes"] = "false";
} else if (enable_dynamic_shapes == "false" || enable_dynamic_shapes == "False") {
ov_options_converted_map["disable_dynamic_shapes"] = "true";
}
if (legacy_ov_options->enable_dynamic_shapes) {
ov_options_converted_map["disable_dynamic_shapes"] = "false";
} else {
ov_options_converted_map["disable_dynamic_shapes"] = "true";
}

// Add new provider option below
ov_options_converted_map["num_streams"] = "1";
return ov_options_converted_map;
Expand Down

0 comments on commit 90e2e85

Please sign in to comment.