From c376c444f279258470ab96d1d6c04faee2e5c241 Mon Sep 17 00:00:00 2001 From: "Wang, Yang" Date: Wed, 22 May 2024 15:47:30 +0800 Subject: [PATCH 1/3] Update. --- src/plugins/auto/src/auto_schedule.cpp | 10 ++++ .../unit/startup_fallback_property_test.cpp | 55 ++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/plugins/auto/src/auto_schedule.cpp b/src/plugins/auto/src/auto_schedule.cpp index 5a5fb2eec0a..6458c32893b 100644 --- a/src/plugins/auto/src/auto_schedule.cpp +++ b/src/plugins/auto/src/auto_schedule.cpp @@ -142,6 +142,16 @@ void AutoSchedule::init() { m_compile_context[CPU].m_device_info = *cpu_iter; m_compile_context[CPU].m_device_info.config[ov::hint::performance_mode.name()] = ov::hint::PerformanceMode::LATENCY; m_compile_context[CPU].m_worker_name = "CPU_HELP"; + if (m_context->m_startup_fallback || m_context->m_runtime_fallback) { + auto& device_config = m_compile_context[CPU].m_device_info.config; + bool is_already_set_cache = device_config.count(ov::cache_dir.name()) + ? !(device_config[ov::cache_dir.name()].as().empty()) + : false; + if (is_already_set_cache) { + device_config[ov::cache_dir.name()] = ""; + LOG_INFO_TAG("Clear cache dir setting for CPU accelerator"); + } + } LOG_INFO_TAG("will load CPU for accelerator"); } else { m_compile_context[CPU].m_is_enabled = false; diff --git a/src/plugins/auto/tests/unit/startup_fallback_property_test.cpp b/src/plugins/auto/tests/unit/startup_fallback_property_test.cpp index 38d155186f3..9749ed5ef43 100644 --- a/src/plugins/auto/tests/unit/startup_fallback_property_test.cpp +++ b/src/plugins/auto/tests/unit/startup_fallback_property_test.cpp @@ -29,6 +29,20 @@ MATCHER_P(MapContains, subMap, "Check if all the elements of the subMap are cont class AutoStartupFallback : public tests::AutoTest, public ::testing::TestWithParam { public: + static std::string getTestCaseNameCacheTest(testing::TestParamInfo obj) { + bool startup_fallback; + ov::AnyMap config; + std::tie(startup_fallback, config) = obj.param; + std::ostringstream result; + result << "_expected_disabling_cache_" << startup_fallback; + result << "_compiled_config_"; + for (auto& item : config) { + result << item.first << "_" << item.second.as() << "_"; + } + auto name = result.str(); + name.pop_back(); + return name; + } void SetUp() override { plugin->set_device_name("AUTO"); ON_CALL(*core, @@ -36,7 +50,8 @@ public: ::testing::Matcher(_), _)) .WillByDefault(Return(mockExeNetwork)); - metaDevices = {{ov::test::utils::DEVICE_CPU, {}, -1}, {ov::test::utils::DEVICE_GPU, {}, -1}}; + metaDevices = {{ov::test::utils::DEVICE_CPU, {ov::cache_dir("test_dir")}, -1}, + {ov::test::utils::DEVICE_GPU, {ov::cache_dir("test_dir")}, -1}}; ON_CALL(*plugin, parse_meta_devices(_, _)).WillByDefault(Return(metaDevices)); ON_CALL(*plugin, get_valid_device) .WillByDefault([](const std::vector& metaDevices, const std::string& netPrecision) { @@ -74,3 +89,41 @@ const std::vector testConfigs = {ConfigParams{true, {{"ENABLE_STAR ConfigParams{false, {{"ENABLE_STARTUP_FALLBACK", "NO"}}}}; INSTANTIATE_TEST_SUITE_P(smoke_Auto_StartupFallback, AutoStartupFallback, ::testing::ValuesIn(testConfigs)); + +using AutoLoadExeNetworkCacheDirSettingTest = AutoStartupFallback; +TEST_P(AutoLoadExeNetworkCacheDirSettingTest, canDisableCacheDirSettingForCPUPlugin) { + // get Parameter + bool is_disable_cache_dir; + ov::AnyMap config; + std::tie(is_disable_cache_dir, config) = this->GetParam(); + EXPECT_CALL(*core, + compile_model(::testing::Matcher&>(_), + ::testing::Matcher(StrEq(ov::test::utils::DEVICE_GPU)), + _)) + .Times(1); + std::map test_map = {{ov::cache_dir.name(), "test_dir"}}; + if (is_disable_cache_dir) { + test_map[ov::cache_dir.name()] = ""; + EXPECT_CALL(*core, + compile_model(::testing::Matcher&>(_), + ::testing::Matcher(StrEq(ov::test::utils::DEVICE_CPU)), + ::testing::Matcher(MapContains(test_map)))) + .Times(1); + } + + ASSERT_NO_THROW(plugin->compile_model(model, config)); +} + +const std::vector testCacheConfigs = { + ConfigParams{true, {ov::intel_auto::enable_startup_fallback(true)}}, + ConfigParams{true, {ov::intel_auto::enable_runtime_fallback(true)}}, + ConfigParams{true, {ov::intel_auto::enable_startup_fallback(true), ov::intel_auto::enable_runtime_fallback(false)}}, + ConfigParams{false, {ov::intel_auto::enable_startup_fallback(false), ov::intel_auto::enable_runtime_fallback(true)}}, + ConfigParams{true, {ov::intel_auto::enable_startup_fallback(true), ov::intel_auto::enable_runtime_fallback(true)}}, + ConfigParams{false, + {ov::intel_auto::enable_startup_fallback(false), ov::intel_auto::enable_runtime_fallback(false)}}}; + +INSTANTIATE_TEST_SUITE_P(smoke_Auto_disableCachingForCPUPlugin, + AutoLoadExeNetworkCacheDirSettingTest, + ::testing::ValuesIn(testCacheConfigs), + AutoLoadExeNetworkCacheDirSettingTest::getTestCaseNameCacheTest); \ No newline at end of file From 77d51a479293c9e35f3c2478b2142c56fa3afd31 Mon Sep 17 00:00:00 2001 From: "Wang, Yang" Date: Mon, 27 May 2024 17:09:40 +0800 Subject: [PATCH 2/3] Update. --- src/plugins/auto/src/auto_schedule.cpp | 14 ++++---------- .../tests/unit/startup_fallback_property_test.cpp | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/plugins/auto/src/auto_schedule.cpp b/src/plugins/auto/src/auto_schedule.cpp index 9598cf5093b..0bbc99df32c 100644 --- a/src/plugins/auto/src/auto_schedule.cpp +++ b/src/plugins/auto/src/auto_schedule.cpp @@ -143,16 +143,6 @@ void AutoSchedule::init() { // if have CPU Device, enable m_compile_context[CPU] if (cpu_iter != m_context->m_device_priorities.end()) { m_compile_context[CPU].m_is_enabled = true; - if (m_context->m_startup_fallback || m_context->m_runtime_fallback) { - auto& device_config = m_compile_context[CPU].m_device_info.config; - bool is_already_set_cache = device_config.count(ov::cache_dir.name()) - ? !(device_config[ov::cache_dir.name()].as().empty()) - : false; - if (is_already_set_cache) { - device_config[ov::cache_dir.name()] = ""; - LOG_INFO_TAG("Clear cache dir setting for CPU accelerator"); - } - } if (!is_actual_cpu) { // user does not set the compiling threads // limit the threads num for compiling @@ -181,6 +171,10 @@ void AutoSchedule::init() { m_compile_context[CPU].m_device_info = *cpu_iter; m_compile_context[CPU].m_device_info.config[ov::hint::performance_mode.name()] = ov::hint::PerformanceMode::LATENCY; + if (m_context->m_startup_fallback || m_context->m_runtime_fallback) { + m_compile_context[CPU].m_device_info.config[ov::cache_dir.name()] = ""; + LOG_INFO_TAG("Clear cache dir setting for CPU accelerator"); + } m_compile_context[CPU].m_worker_name = "CPU_HELP"; LOG_INFO_TAG("will load CPU for accelerator"); } diff --git a/src/plugins/auto/tests/unit/startup_fallback_property_test.cpp b/src/plugins/auto/tests/unit/startup_fallback_property_test.cpp index 9749ed5ef43..6998545ffc4 100644 --- a/src/plugins/auto/tests/unit/startup_fallback_property_test.cpp +++ b/src/plugins/auto/tests/unit/startup_fallback_property_test.cpp @@ -101,9 +101,9 @@ TEST_P(AutoLoadExeNetworkCacheDirSettingTest, canDisableCacheDirSettingForCPUPlu ::testing::Matcher(StrEq(ov::test::utils::DEVICE_GPU)), _)) .Times(1); - std::map test_map = {{ov::cache_dir.name(), "test_dir"}}; + if (is_disable_cache_dir) { - test_map[ov::cache_dir.name()] = ""; + std::map test_map = {{ov::cache_dir.name(), ""}}; EXPECT_CALL(*core, compile_model(::testing::Matcher&>(_), ::testing::Matcher(StrEq(ov::test::utils::DEVICE_CPU)), From 452c2244bc4bd5bc1094c81eb6bffc6d17663c03 Mon Sep 17 00:00:00 2001 From: "Wang, Yang" Date: Tue, 28 May 2024 09:56:02 +0800 Subject: [PATCH 3/3] Update. --- src/plugins/auto/src/auto_schedule.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/auto/src/auto_schedule.cpp b/src/plugins/auto/src/auto_schedule.cpp index 0bbc99df32c..24f610e2f93 100644 --- a/src/plugins/auto/src/auto_schedule.cpp +++ b/src/plugins/auto/src/auto_schedule.cpp @@ -171,7 +171,8 @@ void AutoSchedule::init() { m_compile_context[CPU].m_device_info = *cpu_iter; m_compile_context[CPU].m_device_info.config[ov::hint::performance_mode.name()] = ov::hint::PerformanceMode::LATENCY; - if (m_context->m_startup_fallback || m_context->m_runtime_fallback) { + if (m_compile_context[ACTUALDEVICE].m_device_info.config.count(ov::cache_dir.name()) && + (m_context->m_startup_fallback || m_context->m_runtime_fallback)) { m_compile_context[CPU].m_device_info.config[ov::cache_dir.name()] = ""; LOG_INFO_TAG("Clear cache dir setting for CPU accelerator"); }