Skip to content

Commit

Permalink
Add warnings for corner case runtime options
Browse files Browse the repository at this point in the history
  • Loading branch information
preetha-intel committed Sep 26, 2023
1 parent 2ef1750 commit 9112813
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion onnxruntime/core/providers/openvino/openvino_provider_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,33 @@ struct OpenVINO_Provider : Provider {

std::shared_ptr<IExecutionProviderFactory> CreateExecutionProviderFactory(const void* void_params) override {
auto& params = *reinterpret_cast<const OrtOpenVINOProviderOptions*>(void_params);
std::string device_type = params.device_type;
int num_of_threads = 1;
std::set<std::string> ov_supported_device_types = {"CPU_FP32", "CPU_FP16", "GPU_FP32",
"GPU.0_FP32", "GPU.1_FP32", "GPU_FP16",
"GPU.0_FP16", "GPU.1_FP16",
"NPU_FP16", "NPU_U8"};

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))) {
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', 'NPU_FP16', 'NPU_U8' or from"
" HETERO/MULTI/AUTO options available. \n";
}

num_of_threads = params.num_of_threads;
if (num_of_threads <= 0) {
num_of_threads = 1;
LOGS_DEFAULT(WARNING) << "[OpenVINO-EP] The value for the key 'num_threads' should be in the positive range.\n "
<< "Executing with num_threads=1";
}



return std::make_shared<OpenVINOProviderFactory>(params.device_type, params.enable_vpu_fast_compile,
params.device_id, params.num_of_threads,
params.device_id, num_of_threads,
params.cache_dir,
params.context, params.enable_opencl_throttling,
params.enable_dynamic_shapes);
Expand Down

0 comments on commit 9112813

Please sign in to comment.