Skip to content

Commit 9112813

Browse files
committed
Add warnings for corner case runtime options
1 parent 2ef1750 commit 9112813

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

onnxruntime/core/providers/openvino/openvino_provider_factory.cc

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,33 @@ struct OpenVINO_Provider : Provider {
6464

6565
std::shared_ptr<IExecutionProviderFactory> CreateExecutionProviderFactory(const void* void_params) override {
6666
auto& params = *reinterpret_cast<const OrtOpenVINOProviderOptions*>(void_params);
67+
std::string device_type = params.device_type;
68+
int num_of_threads = 1;
69+
std::set<std::string> ov_supported_device_types = {"CPU_FP32", "CPU_FP16", "GPU_FP32",
70+
"GPU.0_FP32", "GPU.1_FP32", "GPU_FP16",
71+
"GPU.0_FP16", "GPU.1_FP16",
72+
"NPU_FP16", "NPU_U8"};
73+
74+
if (!((ov_supported_device_types.find(device_type) != ov_supported_device_types.end()) ||
75+
(device_type.find("HETERO:") == 0) || (device_type.find("MULTI:") == 0) || (device_type.find("AUTO:") == 0))) {
76+
LOGS_DEFAULT(ERROR) <<
77+
"[ERROR] [OpenVINO] You have selcted wrong configuration value for the key 'device_type'.\n "
78+
"Select from 'CPU_FP32', 'CPU_FP16', 'GPU_FP32', 'GPU.0_FP32', 'GPU.1_FP32', 'GPU_FP16', "
79+
"'GPU.0_FP16', 'GPU.1_FP16', 'NPU_FP16', 'NPU_U8' or from"
80+
" HETERO/MULTI/AUTO options available. \n";
81+
}
82+
83+
num_of_threads = params.num_of_threads;
84+
if (num_of_threads <= 0) {
85+
num_of_threads = 1;
86+
LOGS_DEFAULT(WARNING) << "[OpenVINO-EP] The value for the key 'num_threads' should be in the positive range.\n "
87+
<< "Executing with num_threads=1";
88+
}
89+
90+
91+
6792
return std::make_shared<OpenVINOProviderFactory>(params.device_type, params.enable_vpu_fast_compile,
68-
params.device_id, params.num_of_threads,
93+
params.device_id, num_of_threads,
6994
params.cache_dir,
7095
params.context, params.enable_opencl_throttling,
7196
params.enable_dynamic_shapes);

0 commit comments

Comments
 (0)