Skip to content

Commit 9b245a4

Browse files
[OVEP] Fix for appropriate device not selected (#696)
1 parent ca06b7a commit 9b245a4

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

onnxruntime/core/providers/openvino/openvino_provider_factory.cc

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ std::string ParseDeviceType(std::shared_ptr<OVCore> ov_core, const ProviderOptio
117117
luid_list = split(luid_str, ',');
118118
}
119119

120-
bool all_devices_found = true;
121-
122120
for (auto device : devices_to_check) {
123121
bool device_found = false;
124122
// 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<OVCore> ov_core, const ProviderOptio
137135
// Here we need to find the full device name (with .idx, but without _precision)
138136
if (std::find(std::begin(available_devices), std::end(available_devices), device) != std::end(available_devices))
139137
device_found = true;
138+
if (!device_found) {
139+
ORT_THROW("[ERROR] [OpenVINO] Device ", device, " is not available");
140+
}
140141
if (device_prefix != "CPU" && luid_list.size() > 0) {
141142
for (const auto& dev : available_devices) {
142143
ov::device::LUID ov_luid = OVCore::Get()->core.get_property(dev, ov::device::luid);
@@ -149,7 +150,6 @@ std::string ParseDeviceType(std::shared_ptr<OVCore> ov_core, const ProviderOptio
149150
ORT_THROW(msg);
150151
}
151152
}
152-
all_devices_found = all_devices_found && device_found;
153153
}
154154
if (luid_list.size() > 0) {
155155
std::string ov_luid_devices;
@@ -180,16 +180,9 @@ std::string ParseDeviceType(std::shared_ptr<OVCore> ov_core, const ProviderOptio
180180
selected_device = std::move(ov_luid_devices);
181181
}
182182
}
183-
// If invalid device is chosen error is thrown
184-
if (!all_devices_found) {
185-
ORT_THROW(
186-
"[ERROR] [OpenVINO] You have selected wrong configuration value for the key 'device_type'. "
187-
"Select from 'CPU', 'GPU', 'NPU', 'GPU.x' where x = 0,1,2 and so on or from"
188-
" HETERO/MULTI/AUTO/BATCH options available. \n");
189-
} else {
190-
LOGS_DEFAULT(INFO) << "[OpenVINO-EP] Choosing Device: " << selected_device;
191-
return selected_device;
192-
}
183+
184+
LOGS_DEFAULT(INFO) << "[OpenVINO-EP] Choosing Device: " << selected_device;
185+
return selected_device;
193186
}
194187

195188
void ParseProviderOptions([[maybe_unused]] ProviderInfo& result, [[maybe_unused]] const ProviderOptions& config_options) {}

0 commit comments

Comments
 (0)