Skip to content

Commit

Permalink
Fix : Use LOGS_DEFAULT(ERROR) instead of ORT_THROW for exception due …
Browse files Browse the repository at this point in the history
…to invalid devices. Added check for negative values of num_streams and num of_threads
  • Loading branch information
vthaniel committed Oct 17, 2023
1 parent 60bc49f commit 74ed2a1
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions onnxruntime/core/providers/openvino/openvino_provider_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ struct OpenVINO_Provider : Provider {
"GPU.0_FP16", "GPU.1_FP16"};
if (!((ov_supported_device_types.find(device_type) != ov_supported_device_types.end()) ||
(device_type.find("HETERO:") == 0) || (device_type.find("MULTI:") == 0) || (device_type.find("AUTO:") == 0))) {
ORT_THROW(
"[ERROR] [OpenVINO] You have selcted wrong configuration value for the key 'device_type'. "
"Select from 'CPU_FP32', 'CPU_FP16', 'GPU_FP32', 'GPU.0_FP32', 'GPU.1_FP32', 'GPU_FP16', "
"'GPU.0_FP16', 'GPU.1_FP16' or from"
" HETERO/MULTI/AUTO options available. \n");
LOGS_DEFAULT(ERROR)
<< "[ERROR] [OpenVINO] You have selcted wrong configuration value for the key 'device_type'.\n "
<< "Select from 'CPU_FP32', 'CPU_FP16', 'GPU_FP32', 'GPU.0_FP32', 'GPU.1_FP32', 'GPU_FP16', "
<< "'GPU.0_FP16', 'GPU.1_FP16' or from"
<< " HETERO/MULTI/AUTO options available. \n";
}
}
if (provider_options_map.find("device_id") != provider_options_map.end()) {
Expand All @@ -104,13 +104,17 @@ struct OpenVINO_Provider : Provider {
num_of_threads = std::stoi(provider_options_map.at("num_of_threads"));
if (num_of_threads <= 0) {
num_of_threads = 1;
LOGS_DEFAULT(WARNING) << "[OpenVINO-EP] The value for the key 'num_of_threads' should be in the positive range.\n "

Check warning on line 107 in onnxruntime/core/providers/openvino/openvino_provider_factory.cc

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/providers/openvino/openvino_provider_factory.cc#L107

Tab found; better to use spaces [whitespace/tab] [1]
Raw output
onnxruntime/core/providers/openvino/openvino_provider_factory.cc:107:  Tab found; better to use spaces  [whitespace/tab] [1]
<< "Executing with num_of_threads=1";
}
}

if (provider_options_map.find("num_streams") != provider_options_map.end()) {
num_streams = std::stoi(provider_options_map.at("num_streams"));
if (num_streams <= 0 && num_streams > 8) {
ORT_THROW("[ERROR] [OpenVINO] The value for the key 'num_streams' should be in the range of 1-8 \n");
if (num_streams <= 0 ) {

Check warning on line 114 in onnxruntime/core/providers/openvino/openvino_provider_factory.cc

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/providers/openvino/openvino_provider_factory.cc#L114

Mismatching spaces inside () in if [whitespace/parens] [5]
Raw output
onnxruntime/core/providers/openvino/openvino_provider_factory.cc:114:  Mismatching spaces inside () in if  [whitespace/parens] [5]
num_streams = 1;

Check warning on line 115 in onnxruntime/core/providers/openvino/openvino_provider_factory.cc

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/providers/openvino/openvino_provider_factory.cc#L115

Tab found; better to use spaces [whitespace/tab] [1]
Raw output
onnxruntime/core/providers/openvino/openvino_provider_factory.cc:115:  Tab found; better to use spaces  [whitespace/tab] [1]
LOGS_DEFAULT(WARNING) << "[OpenVINO-EP] The value for the key 'num_streams' should be in the positive range.\n "
<< "Executing with num_streams=1";
}
}
std::string bool_flag = "";
Expand Down

0 comments on commit 74ed2a1

Please sign in to comment.