Skip to content

Commit 36b7203

Browse files
preetha-intelankitm3k
authored andcommitted
Fix the LUID check (#647)
* Fix the LUID check * Address review comments
1 parent f01280a commit 36b7203

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

onnxruntime/core/providers/openvino/openvino_provider_factory.cc

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ std::string ParseDeviceType(std::shared_ptr<OVCore> ov_core, const ProviderOptio
7878
if (supported_device_modes.contains(device_mode)) {
7979
const auto& devices = selected_device.substr(delimit + 1);
8080
devices_to_check = split(devices, ',');
81-
ORT_ENFORCE(devices_to_check.size() > 0, "Modes should have devices listed based on priority");
81+
ORT_ENFORCE(devices_to_check.size() > 0, "Mode AUTO/HETERO/MULTI should have devices listed based on priority");
8282
} else {
8383
ORT_THROW("[ERROR] [OpenVINO] Invalid device_type is selected. Supported modes are AUTO/HETERO/MULTI");
8484
}
@@ -155,16 +155,24 @@ std::string ParseDeviceType(std::shared_ptr<OVCore> ov_core, const ProviderOptio
155155
std::string ov_luid_devices;
156156
for (auto luid_str : luid_list) {
157157
if (ov_luid_map.contains(luid_str)) {
158-
if (!ov_luid_devices.empty()) ov_luid_devices = ov_luid_devices + ",";
159-
ov_luid_devices = ov_luid_devices + ov_luid_map.at(luid_str);
158+
std::string ov_dev = ov_luid_map.at(luid_str);
159+
std::string ov_dev_strip = split(ov_dev, '.')[0];
160+
if (std::find(std::begin(devices_to_check), std::end(devices_to_check), ov_dev) != std::end(devices_to_check) ||
161+
std::find(std::begin(devices_to_check), std::end(devices_to_check), ov_dev_strip) != std::end(devices_to_check)) {
162+
if (!ov_luid_devices.empty()) ov_luid_devices = ov_luid_devices + ",";
163+
ov_luid_devices = ov_luid_devices + ov_dev;
164+
} else {
165+
ORT_THROW(" LUID : ", ov_dev, " does not match with device_type : ", selected_device);
166+
}
160167
} else {
161-
ORT_THROW("Invalid device_luid is set");
168+
ORT_THROW(provider_options.at("device_luid"), " does not exist for the selected device_type : ", selected_device);
162169
}
163170
}
164171
if (!device_mode.empty()) {
165172
selected_device = device_mode + ":" + ov_luid_devices;
166173
for (auto dev_str : devices_to_check) {
167174
auto default_dev = split(dev_str, '.')[0];
175+
168176
if (ov_luid_devices.find(default_dev) == std::string::npos)
169177
selected_device = selected_device + "," + dev_str;
170178
}
@@ -173,13 +181,15 @@ std::string ParseDeviceType(std::shared_ptr<OVCore> ov_core, const ProviderOptio
173181
}
174182
}
175183
// If invalid device is chosen error is thrown
176-
if (!all_devices_found)
184+
if (!all_devices_found) {
177185
ORT_THROW(
178186
"[ERROR] [OpenVINO] You have selected wrong configuration value for the key 'device_type'. "
179187
"Select from 'CPU', 'GPU', 'NPU', 'GPU.x' where x = 0,1,2 and so on or from"
180188
" HETERO/MULTI/AUTO/BATCH options available. \n");
181-
else
189+
} else {
190+
LOGS_DEFAULT(INFO) << "[OpenVINO-EP] Choosing Device: " << selected_device;
182191
return selected_device;
192+
}
183193
}
184194

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

0 commit comments

Comments
 (0)