diff --git a/onnxruntime/core/providers/openvino/openvino_provider_factory.cc b/onnxruntime/core/providers/openvino/openvino_provider_factory.cc index f7e64a9be2c60..55addda04910d 100644 --- a/onnxruntime/core/providers/openvino/openvino_provider_factory.cc +++ b/onnxruntime/core/providers/openvino/openvino_provider_factory.cc @@ -117,8 +117,6 @@ std::string ParseDeviceType(std::shared_ptr ov_core, const ProviderOptio luid_list = split(luid_str, ','); } - bool all_devices_found = true; - for (auto device : devices_to_check) { bool device_found = false; // Check deprecated device format (CPU_FP32, GPU.0_FP16, etc.) and remove the suffix in place @@ -137,6 +135,9 @@ std::string ParseDeviceType(std::shared_ptr ov_core, const ProviderOptio // Here we need to find the full device name (with .idx, but without _precision) if (std::find(std::begin(available_devices), std::end(available_devices), device) != std::end(available_devices)) device_found = true; + if (!device_found) { + ORT_THROW("[ERROR] [OpenVINO] Device ", device, " is not available"); + } if (device_prefix != "CPU" && luid_list.size() > 0) { for (const auto& dev : available_devices) { ov::device::LUID ov_luid = OVCore::Get()->core.get_property(dev, ov::device::luid); @@ -149,7 +150,6 @@ std::string ParseDeviceType(std::shared_ptr ov_core, const ProviderOptio ORT_THROW(msg); } } - all_devices_found = all_devices_found && device_found; } if (luid_list.size() > 0) { std::string ov_luid_devices; @@ -180,16 +180,9 @@ std::string ParseDeviceType(std::shared_ptr ov_core, const ProviderOptio selected_device = std::move(ov_luid_devices); } } - // If invalid device is chosen error is thrown - if (!all_devices_found) { - ORT_THROW( - "[ERROR] [OpenVINO] You have selected wrong configuration value for the key 'device_type'. " - "Select from 'CPU', 'GPU', 'NPU', 'GPU.x' where x = 0,1,2 and so on or from" - " HETERO/MULTI/AUTO/BATCH options available. \n"); - } else { - LOGS_DEFAULT(INFO) << "[OpenVINO-EP] Choosing Device: " << selected_device; - return selected_device; - } + + LOGS_DEFAULT(INFO) << "[OpenVINO-EP] Choosing Device: " << selected_device; + return selected_device; } void ParseProviderOptions([[maybe_unused]] ProviderInfo& result, [[maybe_unused]] const ProviderOptions& config_options) {}