From 129772253e129f6bcc424f385ab768dcd0183f24 Mon Sep 17 00:00:00 2001 From: Feng Wang Date: Thu, 23 Oct 2025 13:10:28 +0800 Subject: [PATCH 1/2] Change ep device selection priority --- src/models/model.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/models/model.cpp b/src/models/model.cpp index 07476662d..8b01b9ad2 100644 --- a/src/models/model.cpp +++ b/src/models/model.cpp @@ -661,19 +661,18 @@ DeviceInterface* SetProviderSessionOptions(OrtSessionOptions& session_options, std::optional config_device_id = resolved_device_filtering.hardware_device_id; std::optional config_vendor_id = resolved_device_filtering.hardware_vendor_id; std::optional config_device_type_enum = resolved_device_filtering.hardware_device_type; - // for OpenVINO, use "device_type" in provider_options exclusively if it's provided + // for OpenVINO, fallback to "device_type" in provider_options if no device filtering is specified std::optional config_ov_device_type = std::nullopt; - if (provider_options.name == "OpenVINO") { + if (provider_options.name == "OpenVINO" && + !config_device_id.has_value() && + !config_vendor_id.has_value() && + !config_device_type_enum.has_value()) { for (auto& option : provider_options.options) { if (option.first == "device_type") { config_ov_device_type = option.second; } } - if (config_ov_device_type.has_value()) { - config_device_id = std::nullopt; - config_vendor_id = std::nullopt; - config_device_type_enum = std::nullopt; - } else if (!(config_device_id.has_value() || config_vendor_id.has_value() || config_device_type_enum.has_value())) { + if (!config_ov_device_type.has_value()) { config_ov_device_type = "CPU"; } } From 9cb34e88f741589bcf3b84139bc23fb590d1cf55 Mon Sep 17 00:00:00 2001 From: Feng Wang Date: Fri, 31 Oct 2025 13:27:09 +0800 Subject: [PATCH 2/2] format code --- src/models/model.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/models/model.cpp b/src/models/model.cpp index 8b01b9ad2..3bc301510 100644 --- a/src/models/model.cpp +++ b/src/models/model.cpp @@ -664,9 +664,9 @@ DeviceInterface* SetProviderSessionOptions(OrtSessionOptions& session_options, // for OpenVINO, fallback to "device_type" in provider_options if no device filtering is specified std::optional config_ov_device_type = std::nullopt; if (provider_options.name == "OpenVINO" && - !config_device_id.has_value() && - !config_vendor_id.has_value() && - !config_device_type_enum.has_value()) { + !config_device_id.has_value() && + !config_vendor_id.has_value() && + !config_device_type_enum.has_value()) { for (auto& option : provider_options.options) { if (option.first == "device_type") { config_ov_device_type = option.second;