diff --git a/src/inference/src/dev/core_impl.cpp b/src/inference/src/dev/core_impl.cpp index e0e2fb109dc642..4400b78922e5d0 100644 --- a/src/inference/src/dev/core_impl.cpp +++ b/src/inference/src/dev/core_impl.cpp @@ -783,8 +783,8 @@ ov::SoPtr ov::CoreImpl::compile_model(const std::shared_ptr< // will consume ov::cache_dir if plugin not support it auto 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)) { - CacheContent cacheContent{cacheManager, parsed._core_config.get_enable_mmap()}; + if (cacheManager && device_supports_model_caching(plugin, parsed._config) && !is_proxy_device(plugin)) { + CacheContent cacheContent{cacheManager}; cacheContent.blobId = ov::ModelCache::compute_hash(model, create_compile_config(plugin, parsed._config)); std::unique_ptr lock = cacheGuard.get_hash_lock(cacheContent.blobId); res = load_model_from_cache(cacheContent, plugin, parsed._config, ov::SoPtr{}, [&]() { @@ -817,8 +817,8 @@ ov::SoPtr ov::CoreImpl::compile_model(const std::shared_ptr< // will consume ov::cache_dir if plugin not support it auto 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)) { - CacheContent cacheContent{cacheManager, parsed._core_config.get_enable_mmap()}; + if (cacheManager && device_supports_model_caching(plugin, parsed._config) && !is_proxy_device(plugin)) { + CacheContent cacheContent{cacheManager}; cacheContent.blobId = ov::ModelCache::compute_hash(model, create_compile_config(plugin, parsed._config)); std::unique_ptr lock = cacheGuard.get_hash_lock(cacheContent.blobId); res = load_model_from_cache(cacheContent, plugin, parsed._config, context, [&]() { @@ -841,7 +841,7 @@ ov::SoPtr ov::CoreImpl::compile_model(const std::string& mod // will consume ov::cache_dir if plugin not support it auto 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 cache CoreConfig::remove_core_skip_cache_dir(parsed._config); CacheContent cacheContent{cacheManager, parsed._core_config.get_enable_mmap(), model_path}; @@ -869,8 +869,8 @@ ov::SoPtr ov::CoreImpl::compile_model(const std::string& mod // will consume ov::cache_dir if plugin not support it auto 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)) { - CacheContent cacheContent{cacheManager, parsed._core_config.get_enable_mmap()}; + if (cacheManager && device_supports_model_caching(plugin, parsed._config) && !is_proxy_device(plugin)) { + CacheContent cacheContent{cacheManager}; cacheContent.blobId = ov::ModelCache::compute_hash(model_str, weights, create_compile_config(plugin, parsed._config)); std::unique_ptr lock = cacheGuard.get_hash_lock(cacheContent.blobId); @@ -1387,8 +1387,8 @@ bool ov::CoreImpl::device_supports_internal_property(const ov::Plugin& plugin, c return 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.hpp index 85417175c22556..090d6e612125c3 100644 --- a/src/inference/src/dev/core_impl.hpp +++ b/src/inference/src/dev/core_impl.hpp @@ -207,7 +207,7 @@ class CoreImpl : public ov::ICore, public std::enable_shared_from_this& context, std::function()> 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.cpp index 40207bac9087fa..8530c01893e31f 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& argument return {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.hpp index 14a5adebbab3a4..1ecbc8cc162047 100644 --- a/src/inference/src/dev/plugin.hpp +++ b/src/inference/src/dev/plugin.hpp @@ -74,7 +74,7 @@ class Plugin { T get_property(const ov::Property& property, const AnyMap& arguments) const { return get_property(property.name(), arguments).template as(); } - bool supports_model_caching() const; + bool supports_model_caching(const AnyMap& arguments = {}) const; }; } // namespace ov diff --git a/src/plugins/auto/src/auto_schedule.cpp b/src/plugins/auto/src/auto_schedule.cpp index c504e8e4457870..3c32bc506b184b 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& model) { try_to_compile_model(*context_ptr, model); if (context_ptr->m_is_load_success) { + // release cloned model here + const_cast&>(model).reset(); if (context_ptr->m_worker_name.empty()) { context_ptr->m_worker_name = context_ptr->m_device_info.device_name; } diff --git a/src/plugins/auto/src/plugin.cpp b/src/plugins/auto/src/plugin.cpp index 2371107281d630..9209535142ff2e 100644 --- a/src/plugins/auto/src/plugin.cpp +++ b/src/plugins/auto/src/plugin.cpp @@ -163,7 +163,7 @@ std::vector Plugin::parse_meta_devices(const std::string& pri auto 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 ""; } }; @@ -188,7 +188,6 @@ std::vector Plugin::parse_meta_devices(const std::string& pri bool enable_device_priority = (prioritiesIter != properties.end()) && check_priority_config(prioritiesIter->second.as()); - 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); @@ -206,9 +205,27 @@ std::vector Plugin::parse_meta_devices(const std::string& pri ov::DeviceIDParser parsed{device_name}; std::string deviceid = parsed.get_device_id(); std::vector 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 device_list_with_id = {}; + try { + auto device_id_list = get_core() + ->get_property(parsed.get_device_name(), ov::available_devices.name(), {}) + .as>(); + 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)); } @@ -281,11 +298,29 @@ 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 device_list = arguments.count(ov::device::priorities.name()) + ? m_plugin_config.parse_priorities_devices( + arguments.at(ov::device::priorities.name()).as()) + : get_core()->get_available_devices(); + bool enable_startup_cpu = arguments.count(ov::intel_auto::enable_startup_fallback.name()) + ? arguments.at(ov::intel_auto::enable_startup_fallback.name()).as() + : true; + bool enable_runtime_cpu = arguments.count(ov::intel_auto::enable_runtime_fallback.name()) + ? arguments.at(ov::intel_auto::enable_runtime_fallback.name()).as() + : true; + bool enable_cpu = enable_startup_cpu || enable_runtime_cpu; std::vector 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) { + auto real_device = device[0] == '-' ? device.substr(1) : device; + if (real_device.find("CPU") != std::string::npos && !enable_cpu) { + continue; + } + try { + auto devCapabilities = get_core()->get_property(real_device, ov::device::capabilities); + capabilities.insert(capabilities.end(), devCapabilities.begin(), devCapabilities.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()))); @@ -460,7 +495,14 @@ std::shared_ptr Plugin::compile_model_impl(const std::string if (is_cumulative) { impl = std::make_shared(cloned_model, shared_from_this(), device_context, auto_s_context, scheduler); } else { - impl = std::make_shared(cloned_model, shared_from_this(), device_context, auto_s_context, scheduler); + auto model = auto_s_context->m_model; + if (std::static_pointer_cast(scheduler)->m_compile_context[ACTUALDEVICE].m_is_already) { + // release cloned model here if actual device finish compiling model. + model.reset(); + auto_s_context->m_model.reset(); + } + impl = + std::make_shared(model, shared_from_this(), device_context, auto_s_context, scheduler); } return impl; } @@ -656,7 +698,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 { @@ -667,17 +708,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 devices_merged; - if (device_list_config != properties.end() && !device_list_config->second.empty()) { + if (device_list_config != properties.end() && !(device_list_config->second.as().empty())) { auto priorities = device_list_config->second; // parsing the string and splitting the comma-separated tokens std::vector devices_to_be_merged = m_plugin_config.parse_priorities_devices(priorities.as()); @@ -718,7 +750,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); } @@ -728,8 +762,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 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() + : true; + bool enable_runtime_cpu = + properties.count(ov::intel_auto::enable_runtime_fallback.name()) + ? properties.at(ov::intel_auto::enable_runtime_fallback.name()).as() + : 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>(); + 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 @@ -761,7 +825,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.cpp index 0da64c09829d69..bd63ad90c2194e 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 @@ class MockPluginSupportBatchAndContext : public MockPluginBase { 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 rwProperties{RW_property(ov::num_streams.name()), @@ -581,6 +584,9 @@ class MockPluginSupportBatchAndContext : public MockPluginBase { 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 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 @@ class MockPlugin : public MockPluginBase { else if (it.first == ov::enable_profiling.name()) m_profiling = it.second.as(); else if (it.first == ov::device::id.name()) - continue; + m_id = it.second.as(); else if (it.first == ov::cache_dir.name()) continue; else @@ -659,6 +665,8 @@ class MockPlugin : public MockPluginBase { ov::Any get_property(const std::string& name, const ov::AnyMap& arguments) const override { const std::vector 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 rwProperties{RW_property(ov::num_streams.name()), @@ -685,11 +693,16 @@ class MockPlugin : public MockPluginBase { 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 caching_properties = {ov::device::uuid}; + std::vector 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 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 @@ class MockPlugin : public MockPluginBase { 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.cpp index b2331aa4192deb..239b6fd48d9a65 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 availableDevs = {"CPU", "GPU.0", "GPU.1"}; ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevs)); + std::vector 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.cpp index da56e247bcb47b..e5798855b1a2ec 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 @@ class LoadNetworkWithSecondaryConfigsMockTest : public tests::AutoTest, public : void SetUp() override { std::vector availableDevs = {"CPU", "GPU"}; ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevs)); + std::vector 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&>(_), ::testing::Matcher(StrEq(ov::test::utils::DEVICE_CPU)), @@ -262,6 +265,9 @@ class CompiledModelPropertyMockTest : public tests::AutoTest, public ::testing:: std::tie(deviceName, devicePriorities, isSupportProperty, properties) = GetParam(); std::vector availableDevs = {"CPU", "GPU"}; ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevs)); + std::vector 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&>(_), ::testing::Matcher(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.cpp index b22b53d983f283..6d5ab950659659 100644 --- a/src/plugins/auto/tests/unit/ctput_test.cpp +++ b/src/plugins/auto/tests/unit/ctput_test.cpp @@ -27,6 +27,9 @@ class LoadNetworkWithCTPUTMockTest : public tests::AutoTest, public ::testing::T void SetUp() override { std::vector availableDevs = {"CPU", "GPU"}; ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevs)); + std::vector 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&>(_), ::testing::Matcher(StrEq(ov::test::utils::DEVICE_CPU)), @@ -148,6 +151,9 @@ class AutoCTPUTCallMulti : public tests::AutoTest, public ::testing::TestWithPar void SetUp() override { std::vector availableDevs = {"CPU", "GPU"}; ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevs)); + std::vector 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&>(_), ::testing::Matcher(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.cpp index 18d35ee56d4cfb..6f83cad9e97e4a 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 @@ class AutoDefaultPerfHintTest : public tests::AutoTest, public ::testing::TestWi void SetUp() override { std::vector availableDevs = {"CPU", "GPU"}; ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevs)); + std::vector 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&>(_), diff --git a/src/plugins/auto/tests/unit/dynamic_output_test.cpp b/src/plugins/auto/tests/unit/dynamic_output_test.cpp index c0902b38ce5d46..45e1d01011671c 100644 --- a/src/plugins/auto/tests/unit/dynamic_output_test.cpp +++ b/src/plugins/auto/tests/unit/dynamic_output_test.cpp @@ -60,6 +60,9 @@ void DynamicOutputInferenceTest::SetUp() { std::tie(priorityList, targetList) = GetParam(); auto targets = targetList.as>(); ON_CALL(*core, get_available_devices()).WillByDefault(Return(targets)); + std::vector 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&>(_), diff --git a/src/plugins/auto/tests/unit/get_device_list.cpp b/src/plugins/auto/tests/unit/get_device_list.cpp index 7af02c37478e46..ff7267c19a0eaf 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 availableDevs = {"CPU", "GPU", "NPU"}; const std::vector availableDevsWithId = {"CPU", "GPU.0", "GPU.1", "NPU"}; -using Params = std::tuple; +using Params = std::tuple; using ConfigParams = std::tuple, // Available devices retrieved from Core Params // Params {devicePriority, expect metaDevices} >; @@ -20,11 +20,13 @@ class GetDeviceListTest : public tests::AutoTest, public ::testing::TestWithPara std::string priorityDevices; std::string metaDevices; std::vector 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 availableDevs; + int expectedTimes = 0; std::tie(availableDevs, priorityAndMetaDev) = this->GetParam(); - std::tie(priorityDevices, metaDevices) = priorityAndMetaDev; - + std::tie(priorityDevices, metaDevices, expectedTimes) = priorityAndMetaDev; + std::vector 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 availableDevs; + int expectedTimes = 0; std::tie(availableDevs, priorityAndMetaDev) = this->GetParam(); - std::tie(priorityDevices, metaDevices) = priorityAndMetaDev; - + std::tie(priorityDevices, metaDevices, expectedTimes) = priorityAndMetaDev; + std::vector 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 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 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 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 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.cpp index 6915b14f2d9019..206b0b7599f953 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 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, {}));