OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[AUTO] Refine the logic of creating HW plugins in AUTO (#27691)
Wang, Yangbd91467d9c0c
diff --git a/src/inference/src/dev/core_impl.cpp b/src/inference/src/dev/core_impl.cppindex 9a6d38a1189..e3150c1ce4e 100644--- a/src/inference/src/dev/core_impl.cpp+++ b/src/inference/src/dev/core_impl.cpp@@ -774,7 +774,7 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<// will consume ov::cache_dir if plugin not support itauto cacheManager = parsed._core_config.get_cache_config_for_device(plugin, parsed._config)._cacheManager;// Skip caching for proxy plugin. HW plugin will load network from the cache- if (cacheManager && device_supports_model_caching(plugin) && !is_proxy_device(plugin)) {+ if (cacheManager && device_supports_model_caching(plugin, parsed._config) && !is_proxy_device(plugin)) {CacheContent cacheContent{cacheManager, parsed._core_config.get_enable_mmap()};cacheContent.blobId = ov::ModelCache::compute_hash(model, create_compile_config(plugin, parsed._config));std::unique_ptr<CacheGuardEntry> lock = cacheGuard.get_hash_lock(cacheContent.blobId);@@ -808,7 +808,7 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<// will consume ov::cache_dir if plugin not support itauto cacheManager = parsed._core_config.get_cache_config_for_device(plugin, parsed._config)._cacheManager;// Skip caching for proxy plugin. HW plugin will load network from the cache- if (cacheManager && device_supports_model_caching(plugin) && !is_proxy_device(plugin)) {+ if (cacheManager && device_supports_model_caching(plugin, parsed._config) && !is_proxy_device(plugin)) {CacheContent cacheContent{cacheManager, parsed._core_config.get_enable_mmap()};cacheContent.blobId = ov::ModelCache::compute_hash(model, create_compile_config(plugin, parsed._config));std::unique_ptr<CacheGuardEntry> lock = cacheGuard.get_hash_lock(cacheContent.blobId);@@ -832,7 +832,7 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::string& mod// will consume ov::cache_dir if plugin not support itauto cacheManager = parsed._core_config.get_cache_config_for_device(plugin, parsed._config)._cacheManager;- if (cacheManager && device_supports_model_caching(plugin) && !is_proxy_device(plugin)) {+ if (cacheManager && device_supports_model_caching(plugin, parsed._config) && !is_proxy_device(plugin)) {// Skip caching for proxy plugin. HW plugin will load network from the cacheCoreConfig::remove_core_skip_cache_dir(parsed._config);CacheContent cacheContent{cacheManager, parsed._core_config.get_enable_mmap(), model_path};@@ -860,7 +860,7 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::string& mod// will consume ov::cache_dir if plugin not support itauto cacheManager = parsed._core_config.get_cache_config_for_device(plugin, parsed._config)._cacheManager;// Skip caching for proxy plugin. HW plugin will load network from the cache- if (cacheManager && device_supports_model_caching(plugin) && !is_proxy_device(plugin)) {+ if (cacheManager && device_supports_model_caching(plugin, parsed._config) && !is_proxy_device(plugin)) {CacheContent cacheContent{cacheManager, parsed._core_config.get_enable_mmap()};cacheContent.blobId =ov::ModelCache::compute_hash(model_str, weights, create_compile_config(plugin, parsed._config));@@ -1378,8 +1378,8 @@ bool ov::CoreImpl::device_supports_internal_property(const ov::Plugin& plugin, creturn util::contains(plugin.get_property(ov::internal::supported_properties), key);}-bool ov::CoreImpl::device_supports_model_caching(const ov::Plugin& plugin) const {- return plugin.supports_model_caching();+bool ov::CoreImpl::device_supports_model_caching(const ov::Plugin& plugin, const ov::AnyMap& arguments) const {+ return plugin.supports_model_caching(arguments);}bool ov::CoreImpl::device_supports_cache_dir(const ov::Plugin& plugin) const {diff --git a/src/inference/src/dev/core_impl.hpp b/src/inference/src/dev/core_impl.hppindex bb5c1127946..5c09a32aa54 100644--- a/src/inference/src/dev/core_impl.hpp+++ b/src/inference/src/dev/core_impl.hpp@@ -216,7 +216,7 @@ private:const ov::SoPtr<ov::IRemoteContext>& context,std::function<ov::SoPtr<ov::ICompiledModel>()> compile_model_lambda) const;- bool device_supports_model_caching(const ov::Plugin& plugin) const;+ bool device_supports_model_caching(const ov::Plugin& plugin, const ov::AnyMap& origConfig = {}) const;bool device_supports_property(const ov::Plugin& plugin, const ov::PropertyName& key) const;bool device_supports_internal_property(const ov::Plugin& plugin, const ov::PropertyName& key) const;diff --git a/src/inference/src/dev/plugin.cpp b/src/inference/src/dev/plugin.cppindex 9c22b0ae7e7..d213a1674a6 100644--- a/src/inference/src/dev/plugin.cpp+++ b/src/inference/src/dev/plugin.cpp@@ -101,10 +101,11 @@ ov::Any ov::Plugin::get_property(const std::string& name, const AnyMap& argumentreturn {m_ptr->get_property(name, arguments), {m_so}};}-bool ov::Plugin::supports_model_caching() const {+bool ov::Plugin::supports_model_caching(const ov::AnyMap& arguments) const {bool supported(false);- supported = util::contains(get_property(ov::supported_properties), ov::device::capabilities) &&- util::contains(get_property(ov::device::capabilities), ov::device::capability::EXPORT_IMPORT) &&- util::contains(get_property(ov::internal::supported_properties), ov::internal::caching_properties);+ supported =+ util::contains(get_property(ov::supported_properties), ov::device::capabilities) &&+ util::contains(get_property(ov::device::capabilities, arguments), ov::device::capability::EXPORT_IMPORT) &&+ util::contains(get_property(ov::internal::supported_properties), ov::internal::caching_properties);return supported;}diff --git a/src/inference/src/dev/plugin.hpp b/src/inference/src/dev/plugin.hppindex b6968adda5c..419c5c7d2df 100644--- a/src/inference/src/dev/plugin.hpp+++ b/src/inference/src/dev/plugin.hpp@@ -74,7 +74,7 @@ public:T get_property(const ov::Property<T, M>& property, const AnyMap& arguments) const {return get_property(property.name(), arguments).template as<T>();}- bool supports_model_caching() const;+ bool supports_model_caching(const AnyMap& arguments = {}) const;};} // namespace ovdiff --git a/src/plugins/auto/src/auto_schedule.cpp b/src/plugins/auto/src/auto_schedule.cppindex e27ceef580c..aee19e2c11e 100644--- a/src/plugins/auto/src/auto_schedule.cpp+++ b/src/plugins/auto/src/auto_schedule.cpp@@ -101,6 +101,8 @@ void AutoSchedule::init() {auto load_device_task = [&](AutoCompileContext* context_ptr, const std::shared_ptr<ov::Model>& model) {try_to_compile_model(*context_ptr, model);if (context_ptr->m_is_load_success) {+ // release cloned model here+ const_cast<std::shared_ptr<ov::Model>&>(model).reset();if (context_ptr->m_worker_name.empty()) {context_ptr->m_worker_name = context_ptr->m_device_info.device_name;}@@ -187,12 +189,14 @@ void AutoSchedule::init() {} else {customize_helper_context_from_cache_setting(is_actual_cpu, m_compile_context, m_context);}+ std::shared_ptr<ov::Model> model;// initialize the rest members of load contextfor (int i = 0; i < CONTEXTNUM; i++) {if (m_compile_context[i].m_is_enabled) {m_compile_context[i].m_future = m_compile_context[i].m_promise.get_future();auto* context_ptr = &m_compile_context[i];- auto model = m_context->m_model;+ // clone this model if multi HW plugins need to load model in a background thread+ model = !model ? m_context->m_model : m_context->m_model->clone();m_compile_context[i].m_task = std::bind(load_device_task, context_ptr, model);}}@@ -297,6 +301,11 @@ void AutoSchedule::init() {// only one device need to compile model, do not need to compile it asyncm_compile_context[ACTUALDEVICE].m_task();m_passthrough_compiled_model = m_compile_context[ACTUALDEVICE].m_compiled_model;+ if (!m_context->m_bind_buffer) {+ m_worker_requests.clear();+ m_idle_worker_requests.clear();+ m_infer_pipeline_tasks_device_specific.clear();+ }}m_context->m_hw_compiled_model = wait_first_compiled_model_ready();}diff --git a/src/plugins/auto/src/plugin.cpp b/src/plugins/auto/src/plugin.cppindex 5df1d0c1c70..97e90c64e0e 100644--- a/src/plugins/auto/src/plugin.cpp+++ b/src/plugins/auto/src/plugin.cpp@@ -169,7 +169,7 @@ std::vector<DeviceInformation> Plugin::parse_meta_devices(const std::string& priauto device_id = get_core()->get_property(device_name, ov::device::id);return device_id;} catch (ov::Exception&) {- LOG_DEBUG_TAG("get default device id failed for ", device_name.c_str());+ LOG_DEBUG_TAG("get default device id failed for %s", device_name.c_str());return "";}};@@ -194,7 +194,6 @@ std::vector<DeviceInformation> Plugin::parse_meta_devices(const std::string& pribool enable_device_priority = (prioritiesIter != properties.end()) &&check_priority_config(prioritiesIter->second.as<std::string>());- auto device_list = get_core()->get_available_devices();for (auto && d : devices_with_requests) {auto opening_bracket = d.find_first_of('(');auto closing_bracket = d.find_first_of(')', opening_bracket);@@ -212,9 +211,27 @@ std::vector<DeviceInformation> Plugin::parse_meta_devices(const std::string& priov::DeviceIDParser parsed{device_name};std::string deviceid = parsed.get_device_id();std::vector<std::string> same_type_devices;- // if AUTO:GPU case, replace GPU with GPU.0 and GPU.1+if (deviceid.empty()) {- for (auto&& device : device_list) {+ // if AUTO:GPU case, replace GPU with GPU.0 and GPU.1+ std::vector<std::string> device_list_with_id = {};+ try {+ auto device_id_list = get_core()+ ->get_property(parsed.get_device_name(), ov::available_devices.name(), {})+ .as<std::vector<std::string>>();+ for (auto&& device_id : device_id_list) {+ if (device_id.empty())+ continue;+ device_list_with_id.push_back(parsed.get_device_name() + "." + device_id);+ }+ if (device_id_list.empty()) {+ device_id_list.push_back(parsed.get_device_name());+ }+ } catch (const ov::Exception&) {+ device_list_with_id.push_back(parsed.get_device_name());+ LOG_DEBUG_TAG("Failed to get available devices for ", parsed.get_device_name().c_str());+ }+ for (auto&& device : device_list_with_id) {if (device.find(device_name) != std::string::npos) {same_type_devices.push_back(std::move(device));}@@ -287,11 +304,20 @@ ov::Any Plugin::get_property(const std::string& name, const ov::AnyMap& argument} else if (name == ov::device::full_name) {return decltype(ov::device::full_name)::value_type {get_device_name()};} else if (name == ov::device::capabilities.name()) {- auto device_list = get_core()->get_available_devices();+ std::vector<std::string> device_list = arguments.count(ov::device::priorities.name())+ ? m_plugin_config.parse_priorities_devices(+ arguments.at(ov::device::priorities.name()).as<std::string>())+ : get_core()->get_available_devices();std::vector<std::string> capabilities;- for (auto const & device : device_list) {- auto devCapabilities = get_core()->get_property(device, ov::device::capabilities);- capabilities.insert(capabilities.end(), devCapabilities.begin(), devCapabilities.end());+ for (auto const& device : device_list) {+ if (device[0] == '-')+ continue;+ try {+ auto dev_capabilities = get_core()->get_property(device, ov::device::capabilities);+ capabilities.insert(capabilities.end(), dev_capabilities.begin(), dev_capabilities.end());+ } catch (const ov::Exception&) {+ LOG_DEBUG_TAG("Failed to get capabilities for device: ", device.c_str());+ }}std::sort(capabilities.begin(), capabilities.end());capabilities.resize(std::distance(capabilities.begin(), std::unique(capabilities.begin(), capabilities.end())));@@ -405,10 +431,8 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model_impl(const std::stringbool is_cumulative =(auto_s_context->m_performance_hint == ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT) ? true : false;std::list<DeviceInformation> devices_with_priority(support_devices.begin(), support_devices.end());- std::shared_ptr<ov::Model> cloned_model;if (model_path.empty()) {support_devices = filter_device_by_model(support_devices_by_property, model, load_config);- cloned_model = model->clone();} else {// AUTO / MULTI don't support caching explicitly, but can redirect this functionality to actual HW pluginLOG_INFO_TAG("compile model with model path");@@ -431,8 +455,10 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model_impl(const std::string}LOG_INFO_TAG("device:%s, priority:%ld", iter->device_name.c_str(), iter->device_priority);}- // clone the model, in case of reshape conflict- auto_s_context->m_model = cloned_model;+ auto_s_context->m_startup_fallback = load_config.get_property(ov::intel_auto::enable_startup_fallback);+ auto_s_context->m_runtime_fallback = load_config.get_property(ov::intel_auto::enable_runtime_fallback);+ // in case of mismatching shape conflict when AUTO creates the infer requests for actual device with reshaped model+ auto_s_context->m_model = model_path.empty() ? std::const_pointer_cast<ov::Model>(model) : nullptr;auto_s_context->m_model_path = model_path;auto_s_context->m_device_priorities = support_devices;auto_s_context->m_device_priorities_initial = std::move(support_devices);@@ -442,8 +468,6 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model_impl(const std::stringOPENVINO_ASSERT(auto_s_context->m_ov_core);auto_s_context->m_log_tag = get_device_name();auto_s_context->m_model_precision = model_precision;- auto_s_context->m_startup_fallback = load_config.get_property(ov::intel_auto::enable_startup_fallback);- auto_s_context->m_runtime_fallback = load_config.get_property(ov::intel_auto::enable_runtime_fallback);auto_s_context->m_bind_buffer = load_config.get_property(ov::intel_auto::device_bind_buffer);auto_s_context->m_schedule_policy = load_config.get_property(ov::intel_auto::schedule_policy);auto_s_context->m_mtx = m_mtx;@@ -463,9 +487,21 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model_impl(const std::stringLOG_INFO_TAG("underlying hardware does not support hardware context");}if (is_cumulative) {- impl = std::make_shared<AutoCumuCompiledModel>(cloned_model, shared_from_this(), device_context, auto_s_context, scheduler);+ impl = std::make_shared<AutoCumuCompiledModel>(auto_s_context->m_model,+ shared_from_this(),+ device_context,+ auto_s_context,+ scheduler);} else {- impl = std::make_shared<AutoCompiledModel>(cloned_model, shared_from_this(), device_context, auto_s_context, scheduler);+ if (std::static_pointer_cast<AutoSchedule>(scheduler)->m_compile_context[ACTUALDEVICE].m_is_already) {+ // release all the models here if actual device finish compiling model.+ auto_s_context->m_model.reset();+ }+ impl = std::make_shared<AutoCompiledModel>(auto_s_context->m_model,+ shared_from_this(),+ device_context,+ auto_s_context,+ scheduler);}return impl;}@@ -661,7 +697,6 @@ void Plugin::register_priority(const unsigned int& priority, const std::string&std::string Plugin::get_device_list(const ov::AnyMap& properties) const {std::string all_devices;std::string device_architecture;- auto device_list = get_core()->get_available_devices();auto device_list_config = properties.find(ov::device::priorities.name());auto get_gpu_architecture = [&](const std::string& name) -> std::string {try {@@ -672,17 +707,8 @@ std::string Plugin::get_device_list(const ov::AnyMap& properties) const {}return "";};- for (auto&& device : device_list) {- // filter out the supported devices- if (device.find("GPU") != std::string::npos) {- device_architecture = get_gpu_architecture(device);- }- if (!m_plugin_config.is_supported_device(device, device_architecture))- continue;- all_devices += device + ",";- }std::vector<std::string> devices_merged;- if (device_list_config != properties.end() && !device_list_config->second.empty()) {+ if (device_list_config != properties.end() && !(device_list_config->second.as<std::string>().empty())) {auto priorities = device_list_config->second;// parsing the string and splitting the comma-separated tokensstd::vector<std::string> devices_to_be_merged = m_plugin_config.parse_priorities_devices(priorities.as<std::string>());@@ -723,7 +749,9 @@ std::string Plugin::get_device_list(const ov::AnyMap& properties) const {return device.find(".") == std::string::npos ? device + ".0" : device;};if (devices_to_be_merged.empty()) {+ auto device_list = get_core()->get_available_devices();for (auto&& device : device_list) {+ all_devices += device + ",";if (device.find("GPU") != std::string::npos) {device_architecture = get_gpu_architecture(device);}@@ -733,8 +761,38 @@ std::string Plugin::get_device_list(const ov::AnyMap& properties) const {}} else {for (auto&& device : devices_to_be_merged) {+ ov::DeviceIDParser parsed{device};+ std::vector<std::string> device_list = {};+ try {+ if (parsed.get_device_name().find("CPU") != std::string::npos) {+ bool enable_startup_cpu =+ properties.count(ov::intel_auto::enable_startup_fallback.name())+ ? properties.at(ov::intel_auto::enable_startup_fallback.name()).as<bool>()+ : true;+ bool enable_runtime_cpu =+ properties.count(ov::intel_auto::enable_runtime_fallback.name())+ ? properties.at(ov::intel_auto::enable_runtime_fallback.name()).as<bool>()+ : true;+ // Skip to load CPU device if both startup and runtime fallback are disabled+ if (!enable_startup_cpu && !enable_runtime_cpu)+ continue;+ }+ auto device_id_list = get_core()+ ->get_property(parsed.get_device_name(), ov::available_devices.name(), {})+ .as<std::vector<std::string>>();+ for (auto&& device_id : device_id_list) {+ if (device_id.empty())+ continue;+ device_list.push_back(parsed.get_device_name() + "." + device_id);+ }+ if (device_id_list.empty()) {+ device_id_list.push_back(parsed.get_device_name());+ }+ } catch (const ov::Exception&) {+ device_list.push_back(parsed.get_device_name());+ LOG_DEBUG_TAG("no available devices found for %s", device.c_str());+ }if (!is_any_dev(device, device_list)) {- ov::DeviceIDParser parsed{device};auto iter = std::find(devices_merged.begin(), devices_merged.end(), parsed.get_device_name());if (iter != devices_merged.end() && parsed.get_device_name() != device && parsed.get_device_id() == "0")// The device is the device with default device ID (eg. GPU.0) and@@ -766,7 +824,18 @@ std::string Plugin::get_device_list(const ov::AnyMap& properties) const {std::for_each(devices_merged.begin(), devices_merged.end(), [&all_devices](const std::string& device) {all_devices += device + ",";});+ } else {+ auto device_list = get_core()->get_available_devices();+ for (auto&& device : device_list) {+ if (device.find("GPU") != std::string::npos) {+ device_architecture = get_gpu_architecture(device);+ }+ if (!m_plugin_config.is_supported_device(device, device_architecture))+ continue;+ all_devices += device + ",";+ }}+if (all_devices.empty()) {OPENVINO_THROW("Please, check environment due to no supported devices can be used");}diff --git a/src/plugins/auto/tests/functional/behavior/auto_func_test.cpp b/src/plugins/auto/tests/functional/behavior/auto_func_test.cppindex 917dadf0d15..5648fe53cef 100644--- a/src/plugins/auto/tests/functional/behavior/auto_func_test.cpp+++ b/src/plugins/auto/tests/functional/behavior/auto_func_test.cpp@@ -60,6 +60,8 @@ void ov::auto_plugin::tests::AutoFuncTests::SetUp() {if (m_mock_plugins.empty()) {register_plugin_mock_cpu(core, "MOCK_CPU", {});register_plugin_mock_gpu(core, "MOCK_GPU", {});+ core.get_property("MOCK_CPU", ov::device::capabilities.name(), {});+ core.get_property("MOCK_GPU", ov::device::capabilities.name(), {});}model_can_batch = create_model_with_batch_possible();model_cannot_batch = create_model_with_reshape();@@ -537,6 +539,7 @@ public:RO_property(ov::device::type.name()),RO_property(ov::device::uuid.name()),RO_property(ov::device::id.name()),+ RO_property(ov::available_devices.name()),RO_property(ov::intel_gpu::memory_statistics.name())};// the whole config is RW before network is loaded.const std::vector<ov::PropertyName> rwProperties{RW_property(ov::num_streams.name()),@@ -581,6 +584,9 @@ public:return decltype(ov::device::uuid)::value_type{uuid};} else if (name == ov::device::id) {return decltype(ov::device::id)::value_type{m_id};+ } else if (name == ov::available_devices.name()) {+ std::vector<std::string> available_devices = {};+ return decltype(ov::available_devices)::value_type(available_devices);} else if (name == ov::loaded_from_cache.name()) {return m_loaded_from_cache;} else if (name == ov::intel_gpu::memory_statistics) {@@ -648,7 +654,7 @@ public:else if (it.first == ov::enable_profiling.name())m_profiling = it.second.as<bool>();else if (it.first == ov::device::id.name())- continue;+ m_id = it.second.as<std::string>();else if (it.first == ov::cache_dir.name())continue;else@@ -659,6 +665,8 @@ public:ov::Any get_property(const std::string& name, const ov::AnyMap& arguments) const override {const std::vector<ov::PropertyName> roProperties{RO_property(ov::supported_properties.name()),RO_property(ov::device::uuid.name()),+ RO_property(ov::device::id.name()),+ RO_property(ov::available_devices.name()),RO_property(ov::device::capabilities.name())};// the whole config is RW before network is loaded.const std::vector<ov::PropertyName> rwProperties{RW_property(ov::num_streams.name()),@@ -685,11 +693,16 @@ public:capabilities.push_back(ov::device::capability::EXPORT_IMPORT);return decltype(ov::device::capabilities)::value_type(capabilities);} else if (ov::internal::caching_properties == name) {- std::vector<ov::PropertyName> caching_properties = {ov::device::uuid};+ std::vector<ov::PropertyName> caching_properties = {ov::device::uuid, ov::device::id};return decltype(ov::internal::caching_properties)::value_type(caching_properties);} else if (name == ov::device::uuid) {ov::device::UUID uuid = {};return decltype(ov::device::uuid)::value_type{uuid};+ } else if (name == ov::device::id) {+ return decltype(ov::device::id)::value_type{m_id};+ } else if (name == ov::available_devices.name()) {+ std::vector<std::string> available_devices = {};+ return decltype(ov::available_devices)::value_type(available_devices);} else if (name == ov::loaded_from_cache.name()) {return m_loaded_from_cache;}@@ -700,6 +713,7 @@ private:int32_t num_streams{0};bool m_profiling = false;bool m_loaded_from_cache{false};+ std::string m_id;};void ov::auto_plugin::tests::AutoFuncTests::register_plugin_mock_cpu(ov::Core& core,diff --git a/src/plugins/auto/tests/unit/auto_unit_test.cpp b/src/plugins/auto/tests/unit/auto_unit_test.cppindex 224a25b0241..896b583f7d7 100644--- a/src/plugins/auto/tests/unit/auto_unit_test.cpp+++ b/src/plugins/auto/tests/unit/auto_unit_test.cpp@@ -192,6 +192,9 @@ ov::mock_auto_plugin::tests::AutoTest::AutoTest(const MODELTYPE modelType) : Bas.WillByDefault(RETURN_MOCK_VALUE(dgpuFullDeviceName));const std::vector<std::string> availableDevs = {"CPU", "GPU.0", "GPU.1"};ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevs));+ std::vector<std::string> deviceIDs = {"0", "1"};+ ON_CALL(*core, get_property(StrEq("GPU"), StrEq(ov::available_devices.name()), _))+ .WillByDefault(RETURN_MOCK_VALUE(deviceIDs));ON_CALL(*core, get_supported_property).WillByDefault([](const std::string& device, const ov::AnyMap& fullConfigs, const bool keep_core_property = true) {auto item = fullConfigs.find(ov::device::properties.name());ov::AnyMap deviceConfigs;diff --git a/src/plugins/auto/tests/unit/compile_model_property_test.cpp b/src/plugins/auto/tests/unit/compile_model_property_test.cppindex e4cbd808430..00c7903f244 100644--- a/src/plugins/auto/tests/unit/compile_model_property_test.cpp+++ b/src/plugins/auto/tests/unit/compile_model_property_test.cpp@@ -110,6 +110,9 @@ public:void SetUp() override {std::vector<std::string> availableDevs = {"CPU", "GPU"};ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevs));+ std::vector<std::string> deviceIDs = {};+ ON_CALL(*core, get_property(StrEq("GPU"), StrEq(ov::available_devices.name()), _))+ .WillByDefault(RETURN_MOCK_VALUE(deviceIDs));ON_CALL(*core,compile_model(::testing::Matcher<const std::shared_ptr<const ov::Model>&>(_),::testing::Matcher<const std::string&>(StrEq(ov::test::utils::DEVICE_CPU)),@@ -262,6 +265,9 @@ public:std::tie(deviceName, devicePriorities, isSupportProperty, properties) = GetParam();std::vector<std::string> availableDevs = {"CPU", "GPU"};ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevs));+ std::vector<std::string> deviceIDs = {};+ ON_CALL(*core, get_property(StrEq("GPU"), StrEq(ov::available_devices.name()), _))+ .WillByDefault(RETURN_MOCK_VALUE(deviceIDs));ON_CALL(*core,compile_model(::testing::Matcher<const std::shared_ptr<const ov::Model>&>(_),::testing::Matcher<const std::string&>(StrEq(ov::test::utils::DEVICE_CPU)),diff --git a/src/plugins/auto/tests/unit/ctput_test.cpp b/src/plugins/auto/tests/unit/ctput_test.cppindex 33bdb42b063..d6d7d02a006 100644--- a/src/plugins/auto/tests/unit/ctput_test.cpp+++ b/src/plugins/auto/tests/unit/ctput_test.cpp@@ -27,6 +27,9 @@ public:void SetUp() override {std::vector<std::string> availableDevs = {"CPU", "GPU"};ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevs));+ std::vector<std::string> deviceIDs = {};+ ON_CALL(*core, get_property(StrEq("GPU"), StrEq(ov::available_devices.name()), _))+ .WillByDefault(RETURN_MOCK_VALUE(deviceIDs));ON_CALL(*core,compile_model(::testing::Matcher<const std::shared_ptr<const ov::Model>&>(_),::testing::Matcher<const std::string&>(StrEq(ov::test::utils::DEVICE_CPU)),@@ -148,6 +151,9 @@ public:void SetUp() override {std::vector<std::string> availableDevs = {"CPU", "GPU"};ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevs));+ std::vector<std::string> deviceIDs = {};+ ON_CALL(*core, get_property(StrEq("GPU"), StrEq(ov::available_devices.name()), _))+ .WillByDefault(RETURN_MOCK_VALUE(deviceIDs));ON_CALL(*core,compile_model(::testing::Matcher<const std::shared_ptr<const ov::Model>&>(_),::testing::Matcher<const std::string&>(StrEq(ov::test::utils::DEVICE_CPU)),diff --git a/src/plugins/auto/tests/unit/default_perf_hint_test.cpp b/src/plugins/auto/tests/unit/default_perf_hint_test.cppindex 943c71e7eec..e69e3c63142 100644--- a/src/plugins/auto/tests/unit/default_perf_hint_test.cpp+++ b/src/plugins/auto/tests/unit/default_perf_hint_test.cpp@@ -181,6 +181,9 @@ public:void SetUp() override {std::vector<std::string> availableDevs = {"CPU", "GPU"};ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevs));+ std::vector<std::string> deviceIDs = {};+ ON_CALL(*core, get_property(StrEq("GPU"), StrEq(ov::available_devices.name()), _))+ .WillByDefault(RETURN_MOCK_VALUE(deviceIDs));ON_CALL(*core,compile_model(::testing::Matcher<const std::shared_ptr<const ov::Model>&>(_),diff --git a/src/plugins/auto/tests/unit/dynamic_output_test.cpp b/src/plugins/auto/tests/unit/dynamic_output_test.cppindex 8c9d4820b89..6952fd5769a 100644--- a/src/plugins/auto/tests/unit/dynamic_output_test.cpp+++ b/src/plugins/auto/tests/unit/dynamic_output_test.cpp@@ -75,6 +75,9 @@ void DynamicOutputInferenceTest::SetUp() {std::tie(priorityList, targetList) = GetParam();auto targets = targetList.as<std::vector<std::string>>();ON_CALL(*core, get_available_devices()).WillByDefault(Return(targets));+ std::vector<std::string> deviceIDs = {};+ ON_CALL(*core, get_property(StrEq("GPU"), StrEq(ov::available_devices.name()), _))+ .WillByDefault(RETURN_MOCK_VALUE(deviceIDs));for (auto device : targets) {ON_CALL(*core,compile_model(::testing::Matcher<const std::shared_ptr<const ov::Model>&>(_),diff --git a/src/plugins/auto/tests/unit/get_device_list.cpp b/src/plugins/auto/tests/unit/get_device_list.cppindex e1e070e6fe4..e3853deff03 100644--- a/src/plugins/auto/tests/unit/get_device_list.cpp+++ b/src/plugins/auto/tests/unit/get_device_list.cpp@@ -9,7 +9,7 @@ using namespace ov::mock_auto_plugin;const std::vector<std::string> availableDevs = {"CPU", "GPU", "NPU"};const std::vector<std::string> availableDevsWithId = {"CPU", "GPU.0", "GPU.1", "NPU"};-using Params = std::tuple<std::string, std::string>;+using Params = std::tuple<std::string, std::string, int>;using ConfigParams = std::tuple<std::vector<std::string>, // Available devices retrieved from CoreParams // Params {devicePriority, expect metaDevices}>;@@ -20,11 +20,13 @@ public:std::string priorityDevices;std::string metaDevices;std::vector<std::string> availableDevices;+ int expectedTimes = 0;std::tie(availableDevices, priorityAndMetaDev) = obj.param;- std::tie(priorityDevices, metaDevices) = priorityAndMetaDev;+ std::tie(priorityDevices, metaDevices, expectedTimes) = priorityAndMetaDev;std::ostringstream result;result << "priorityDevices_" << priorityDevices;- result << "_expectedDevices" << metaDevices;+ result << "_expectedDevices_" << metaDevices;+ result << "_expectedCallAvailableTimes_" << expectedTimes;result << "_availableDevicesList";std::string devicesStr;for (auto&& device : availableDevices) {@@ -47,12 +49,20 @@ TEST_P(GetDeviceListTest, GetDeviceListTestWithExcludeList) {std::string priorityDevices;std::string metaDevices;std::vector<std::string> availableDevs;+ int expectedTimes = 0;std::tie(availableDevs, priorityAndMetaDev) = this->GetParam();- std::tie(priorityDevices, metaDevices) = priorityAndMetaDev;-+ std::tie(priorityDevices, metaDevices, expectedTimes) = priorityAndMetaDev;+ std::vector<std::string> deviceIDs = {"0", "1"};+ if (availableDevs != availableDevsWithId) {+ deviceIDs.clear();+ if (priorityDevices.find("GPU.0") != std::string::npos)+ deviceIDs.push_back("0");+ }+ ON_CALL(*core, get_property(StrEq("GPU"), StrEq(ov::available_devices.name()), _))+ .WillByDefault(RETURN_MOCK_VALUE(deviceIDs));ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevs));- EXPECT_CALL(*core, get_available_devices()).Times(1);+ EXPECT_CALL(*core, get_available_devices()).Times(expectedTimes);if (metaDevices == "") {EXPECT_THROW(plugin->get_device_list({ov::device::priorities(priorityDevices)}), ov::Exception);} else {@@ -69,14 +79,22 @@ TEST_P(GetDeviceListTestWithNotInteldGPU, GetDeviceListTestWithExcludeList) {std::string priorityDevices;std::string metaDevices;std::vector<std::string> availableDevs;+ int expectedTimes = 0;std::tie(availableDevs, priorityAndMetaDev) = this->GetParam();- std::tie(priorityDevices, metaDevices) = priorityAndMetaDev;-+ std::tie(priorityDevices, metaDevices, expectedTimes) = priorityAndMetaDev;+ std::vector<std::string> deviceIDs = {"0", "1"};+ if (availableDevs != availableDevsWithId) {+ deviceIDs.clear();+ if (priorityDevices.find("GPU.0") != std::string::npos)+ deviceIDs.push_back("0");+ }+ ON_CALL(*core, get_property(StrEq("GPU"), StrEq(ov::available_devices.name()), _))+ .WillByDefault(RETURN_MOCK_VALUE(deviceIDs));ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevs));std::string dgpuArchitecture = "GPU: vendor=0x10DE arch=0";ON_CALL(*core, get_property(StrEq("GPU.1"), StrEq(ov::device::architecture.name()), _)).WillByDefault(RETURN_MOCK_VALUE(dgpuArchitecture));- EXPECT_CALL(*core, get_available_devices()).Times(1);+ EXPECT_CALL(*core, get_available_devices()).Times(expectedTimes);if (metaDevices == "") {EXPECT_THROW(plugin->get_device_list({ov::device::priorities(priorityDevices)}), ov::Exception);} else {@@ -87,87 +105,86 @@ TEST_P(GetDeviceListTestWithNotInteldGPU, GetDeviceListTestWithExcludeList) {}const std::vector<Params> testConfigsWithId = {- Params{" ", " "},- Params{"", "CPU,GPU.0,GPU.1"},- Params{"CPU, ", "CPU, "},- Params{" ,CPU", " ,CPU"},- Params{"CPU,", "CPU"},- Params{"CPU,,GPU", "CPU,GPU.0,GPU.1"},- Params{"CPU, ,GPU", "CPU, ,GPU.0,GPU.1"},- Params{"CPU,GPU,GPU.1", "CPU,GPU.0,GPU.1"},- Params{"CPU,GPU,NPU,INVALID_DEVICE", "CPU,GPU.0,GPU.1,NPU,INVALID_DEVICE"},- Params{"NPU,GPU,CPU,-GPU.0", "NPU,GPU.1,CPU"},- Params{"-GPU.0,GPU,CPU", "GPU.1,CPU"},- Params{"-GPU.0,GPU", "GPU.1"},- Params{"-GPU,GPU.0", "GPU.0"},- Params{"-GPU.0", "CPU,GPU.1"},- Params{"-GPU.0,-GPU.1", "CPU"},- Params{"-GPU.0,-GPU.1,INVALID_DEVICE", "INVALID_DEVICE"},- Params{"-GPU.0,-GPU.1,-INVALID_DEVICE", "CPU"},- Params{"-GPU.0,-GPU.1,-CPU", ""},- Params{"GPU,-GPU.0", "GPU.1"},- Params{"-GPU,CPU", "CPU"},- Params{"-GPU,-CPU", ""},- Params{"GPU.0,-GPU", "GPU.0"},- Params{"-GPU.0,-CPU", "GPU.1"}};--const std::vector<Params> testConfigs = {Params{" ", " "},- Params{"", "CPU,GPU"},- Params{"GPU", "GPU"},- Params{"GPU.0", "GPU.0"},- Params{"GPU,GPU.0", "GPU"},- Params{"CPU", "CPU"},- Params{" ,CPU", " ,CPU"},- Params{" ,GPU", " ,GPU"},- Params{"GPU, ", "GPU, "},- Params{"CPU,GPU", "CPU,GPU"},- Params{"CPU,-GPU", "CPU"},- Params{"CPU,-GPU,GPU.0", "CPU,GPU.0"},- Params{"CPU,-GPU,GPU.1", "CPU,GPU.1"},- Params{"CPU,GPU,-GPU.0", "CPU"},- Params{"CPU,GPU,-GPU.1", "CPU,GPU"},- Params{"CPU,GPU.0,GPU", "CPU,GPU"},- Params{"CPU,GPU,GPU.0", "CPU,GPU"},- Params{"CPU,GPU,GPU.1", "CPU,GPU,GPU.1"},- Params{"CPU,GPU.1,GPU", "CPU,GPU.1,GPU"},- Params{"CPU,NPU", "CPU,NPU"},- Params{"CPU,-NPU", "CPU"},- Params{"INVALID_DEVICE", "INVALID_DEVICE"},- Params{"CPU,-INVALID_DEVICE", "CPU"},- Params{"CPU,INVALID_DEVICE", "CPU,INVALID_DEVICE"},- Params{"-CPU,INVALID_DEVICE", "INVALID_DEVICE"},- Params{"CPU,GPU,NPU", "CPU,GPU,NPU"}};+ Params{" ", " ", 0},+ Params{"", "CPU,GPU.0,GPU.1", 1},+ Params{"CPU, ", "CPU, ", 0},+ Params{" ,CPU", " ,CPU", 0},+ Params{"CPU,", "CPU", 0},+ Params{"CPU,,GPU", "CPU,GPU.0,GPU.1", 0},+ Params{"CPU, ,GPU", "CPU, ,GPU.0,GPU.1", 0},+ Params{"CPU,GPU,GPU.1", "CPU,GPU.0,GPU.1", 0},+ Params{"CPU,GPU,NPU,INVALID_DEVICE", "CPU,GPU.0,GPU.1,NPU,INVALID_DEVICE", 0},+ Params{"NPU,GPU,CPU,-GPU.0", "NPU,GPU.1,CPU", 0},+ Params{"-GPU.0,GPU,CPU", "GPU.1,CPU", 0},+ Params{"-GPU.0,GPU", "GPU.1", 0},+ Params{"-GPU,GPU.0", "GPU.0", 0},+ Params{"-GPU.0", "CPU,GPU.1", 1},+ Params{"-GPU.0,-GPU.1", "CPU", 1},+ Params{"-GPU.0,-GPU.1,INVALID_DEVICE", "INVALID_DEVICE", 0},+ Params{"-GPU.0,-GPU.1,-INVALID_DEVICE", "CPU", 1},+ Params{"-GPU.0,-GPU.1,-CPU", "", 1},+ Params{"GPU,-GPU.0", "GPU.1", 0},+ Params{"-GPU,CPU", "CPU", 0},+ Params{"-GPU,-CPU", "", 1},+ Params{"GPU.0,-GPU", "GPU.0", 0},+ Params{"-GPU.0,-CPU", "GPU.1", 1}};++const std::vector<Params> testConfigs = {Params{" ", " ", 0},+ Params{"", "CPU,GPU", 1},+ Params{"GPU", "GPU", 0},+ Params{"GPU.0", "GPU.0", 0},+ Params{"GPU,GPU.0", "GPU.0", 0},+ Params{"CPU", "CPU", 0},+ Params{" ,CPU", " ,CPU", 0},+ Params{" ,GPU", " ,GPU", 0},+ Params{"GPU, ", "GPU, ", 0},+ Params{"CPU,GPU", "CPU,GPU", 0},+ Params{"CPU,-GPU", "CPU", 0},+ Params{"CPU,-GPU,GPU.0", "CPU,GPU.0", 0},+ Params{"CPU,GPU,-GPU.0", "CPU", 0},+ Params{"CPU,GPU,-GPU.1", "CPU,GPU", 0},+ Params{"CPU,GPU.0,GPU", "CPU,GPU.0", 0},+ Params{"CPU,GPU,GPU.0", "CPU,GPU.0", 0},+ Params{"CPU,GPU,GPU.1", "CPU,GPU,GPU.1", 0},+ Params{"CPU,GPU.1,GPU", "CPU,GPU.1,GPU", 0},+ Params{"CPU,NPU", "CPU,NPU", 0},+ Params{"CPU,-NPU", "CPU", 0},+ Params{"INVALID_DEVICE", "INVALID_DEVICE", 0},+ Params{"CPU,-INVALID_DEVICE", "CPU", 0},+ Params{"CPU,INVALID_DEVICE", "CPU,INVALID_DEVICE", 0},+ Params{"-CPU,INVALID_DEVICE", "INVALID_DEVICE", 0},+ Params{"CPU,GPU,NPU", "CPU,GPU,NPU", 0}};const std::vector<Params> testConfigsWithIdNotInteldGPU = {- Params{" ", " "},- Params{"", "CPU,GPU.0"},- Params{"CPU, ", "CPU, "},- Params{" ,CPU", " ,CPU"},- Params{"CPU,", "CPU"},- Params{"CPU,,GPU", "CPU,GPU.0,GPU.1"},- Params{"CPU, ,GPU", "CPU, ,GPU.0,GPU.1"},- Params{"CPU,GPU,GPU.1", "CPU,GPU.0,GPU.1"},- Params{"CPU,GPU,NPU,INVALID_DEVICE", "CPU,GPU.0,GPU.1,NPU,INVALID_DEVICE"},- Params{"NPU,GPU,CPU,-GPU.0", "NPU,GPU.1,CPU"},- Params{"-GPU.0,GPU,CPU", "GPU.1,CPU"},- Params{"-GPU.0,GPU", "GPU.1"},- Params{"-GPU,GPU.0", "GPU.0"},- Params{"-GPU.0", "CPU"},- Params{"-GPU.0,-GPU.1", "CPU"},- Params{"-GPU.0,-GPU.1,INVALID_DEVICE", "INVALID_DEVICE"},- Params{"-GPU.0,-GPU.1,-INVALID_DEVICE", "CPU"},- Params{"-GPU.0,-GPU.1,-CPU", ""},- Params{"GPU,-GPU.0", "GPU.1"},- Params{"GPU.0,-GPU", "GPU.0"},- Params{"GPU", "GPU.0,GPU.1"},- Params{"GPU.0", "GPU.0"},- Params{"GPU.1", "GPU.1"},- Params{"-CPU", "GPU.0"},- Params{"-CPU,-GPU", ""},- Params{"-CPU,-GPU.0", ""},- Params{"-CPU,-GPU.1", "GPU.0"},- Params{"-GPU,CPU", "CPU"},- Params{"-GPU.0,-CPU", ""}};+ Params{" ", " ", 0},+ Params{"", "CPU,GPU.0", 1},+ Params{"CPU, ", "CPU, ", 0},+ Params{" ,CPU", " ,CPU", 0},+ Params{"CPU,", "CPU", 0},+ Params{"CPU,,GPU", "CPU,GPU.0,GPU.1", 0},+ Params{"CPU, ,GPU", "CPU, ,GPU.0,GPU.1", 0},+ Params{"CPU,GPU,GPU.1", "CPU,GPU.0,GPU.1", 0},+ Params{"CPU,GPU,NPU,INVALID_DEVICE", "CPU,GPU.0,GPU.1,NPU,INVALID_DEVICE", 0},+ Params{"NPU,GPU,CPU,-GPU.0", "NPU,GPU.1,CPU", 0},+ Params{"-GPU.0,GPU,CPU", "GPU.1,CPU", 0},+ Params{"-GPU.0,GPU", "GPU.1", 0},+ Params{"-GPU,GPU.0", "GPU.0", 0},+ Params{"-GPU.0", "CPU", 1},+ Params{"-GPU.0,-GPU.1", "CPU", 1},+ Params{"-GPU.0,-GPU.1,INVALID_DEVICE", "INVALID_DEVICE", 0},+ Params{"-GPU.0,-GPU.1,-INVALID_DEVICE", "CPU", 1},+ Params{"-GPU.0,-GPU.1,-CPU", "", 1},+ Params{"GPU,-GPU.0", "GPU.1", 0},+ Params{"GPU.0,-GPU", "GPU.0", 0},+ Params{"GPU", "GPU.0,GPU.1", 0},+ Params{"GPU.0", "GPU.0", 0},+ Params{"GPU.1", "GPU.1", 0},+ Params{"-CPU", "GPU.0", 1},+ Params{"-CPU,-GPU", "", 1},+ Params{"-CPU,-GPU.0", "", 1},+ Params{"-CPU,-GPU.1", "GPU.0", 1},+ Params{"-GPU,CPU", "CPU", 0},+ Params{"-GPU.0,-CPU", "", 1}};INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests_GetDeviceListWithID,GetDeviceListTest,diff --git a/src/plugins/auto/tests/unit/parse_meta_device_test.cpp b/src/plugins/auto/tests/unit/parse_meta_device_test.cppindex 7b12a1d2b16..fcd2b16e841 100644--- a/src/plugins/auto/tests/unit/parse_meta_device_test.cpp+++ b/src/plugins/auto/tests/unit/parse_meta_device_test.cpp@@ -78,7 +78,7 @@ using ParseMetaDeviceNoIDTest = ParseMetaDeviceTest;TEST_P(ParseMetaDeviceTest, ParseMetaDevicesWithPriority) {EXPECT_CALL(*plugin, parse_meta_devices(_, _)).Times(1);EXPECT_CALL(*core, get_property(_, _, _)).Times(AnyNumber());- EXPECT_CALL(*core, get_available_devices()).Times(1);+ EXPECT_CALL(*core, get_available_devices()).Times(0);EXPECT_CALL(*core, get_supported_property(_, _, _)).Times(expectedTimes);if (throwException) {ASSERT_ANY_THROW(plugin->parse_meta_devices(priorityDevices, {}));@@ -92,7 +92,7 @@ TEST_P(ParseMetaDeviceTest, ParseMetaDevicesWithPriority) {TEST_P(ParseMetaDeviceTest, ParseMetaDevicesNotWithPriority) {EXPECT_CALL(*plugin, parse_meta_devices(_, _)).Times(1 + !throwException);EXPECT_CALL(*core, get_property(_, _, _)).Times(AnyNumber());- EXPECT_CALL(*core, get_available_devices()).Times(1 + !throwException);+ EXPECT_CALL(*core, get_available_devices()).Times(0);if (throwException) {ASSERT_ANY_THROW(plugin->parse_meta_devices(priorityDevices, {}));} else {@@ -111,9 +111,12 @@ TEST_P(ParseMetaDeviceTest, ParseMetaDevicesNotWithPriority) {TEST_P(ParseMetaDeviceNoIDTest, ParseMetaDevices) {ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevsNoID));+ std::vector<std::string> deviceIDs = {};+ ON_CALL(*core, get_property(StrEq("GPU"), StrEq(ov::available_devices.name()), _))+ .WillByDefault(RETURN_MOCK_VALUE(deviceIDs));EXPECT_CALL(*plugin, parse_meta_devices(_, _)).Times(1);EXPECT_CALL(*core, get_property(_, _, _)).Times(AnyNumber());- EXPECT_CALL(*core, get_available_devices()).Times(1);+ EXPECT_CALL(*core, get_available_devices()).Times(0);EXPECT_CALL(*core, get_supported_property(_, _, _)).Times(expectedTimes);if (throwException) {ASSERT_ANY_THROW(plugin->parse_meta_devices(priorityDevices, {}));