Skip to content

Commit 5ce1f7b

Browse files
authored
Merge branch 'ovep-develop' into ovep-develop
2 parents 5dd8fc5 + 25912f7 commit 5ce1f7b

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

onnxruntime/core/providers/openvino/backends/basic_backend.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Licensed under the MIT License
33

44
#include <map>
5+
#include <unordered_set>
6+
57
#include <string>
68
#include <memory>
79
#include <sstream>
@@ -222,6 +224,15 @@ void BasicBackend::PopulateConfigValue(ov::AnyMap& device_config) {
222224
}
223225
}
224226
}
227+
auto find_device_type_mode = [&](const std::string& device_type) -> std::string {
228+
std::string device_mode = "";
229+
auto delimiter_pos = device_type.find(':');
230+
if (delimiter_pos != std::string::npos) {
231+
std::stringstream str_stream(device_type.substr(0, delimiter_pos));
232+
std::getline(str_stream, device_mode, ',');
233+
}
234+
return device_mode;
235+
};
225236

226237
// Parse device types like "AUTO:CPU,GPU" and extract individual devices
227238
auto parse_individual_devices = [&](const std::string& device_type) -> std::vector<std::string> {
@@ -270,8 +281,14 @@ void BasicBackend::PopulateConfigValue(ov::AnyMap& device_config) {
270281
if (session_context_.device_type.find("AUTO") == 0 ||
271282
session_context_.device_type.find("HETERO") == 0 ||
272283
session_context_.device_type.find("MULTI") == 0) {
284+
//// Parse to get the device mode (e.g., "AUTO:CPU,GPU" -> "AUTO")
285+
std::unordered_set<std::string> supported_mode = {"AUTO", "HETERO", "MULTI"};
286+
auto device_mode = find_device_type_mode(session_context_.device_type);
287+
ORT_ENFORCE(supported_mode.find(device_mode)!=supported_mode.end(), " Invalid device mode is passed : " , session_context_.device_type);
273288
// Parse individual devices (e.g., "AUTO:CPU,GPU" -> ["CPU", "GPU"])
274289
auto individual_devices = parse_individual_devices(session_context_.device_type);
290+
if (!device_mode.empty()) individual_devices.emplace_back(device_mode);
291+
275292
// Set properties only for individual devices (e.g., "CPU", "GPU")
276293
for (const std::string& device : individual_devices) {
277294
if (target_config.count(device)) {

onnxruntime/core/providers/openvino/openvino_provider_factory.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Licensed under the MIT License
33

44
#include <map>
5+
#include <set>
6+
57
#include <utility>
68
#include "core/providers/shared_library/provider_api.h"
79
#include "core/providers/openvino/openvino_provider_factory.h"
@@ -216,9 +218,9 @@ struct OpenVINO_Provider : Provider {
216218

217219
for (auto& [key, value] : json_config.items()) {
218220
ov::AnyMap inner_map;
219-
221+
std::set<std::string> valid_ov_devices = {"CPU", "GPU", "NPU", "AUTO", "HETERO", "MULTI"};
220222
// Ensure the key is one of "CPU", "GPU", or "NPU"
221-
if (key != "CPU" && key != "GPU" && key != "NPU") {
223+
if (valid_ov_devices.find(key) == valid_ov_devices.end()) {
222224
LOGS_DEFAULT(WARNING) << "Unsupported device key: " << key << ". Skipping entry.\n";
223225
continue;
224226
}

0 commit comments

Comments
 (0)