From 3f4c53a77976da6495afff74660fc2ee07e2f7f7 Mon Sep 17 00:00:00 2001 From: yanlan song Date: Fri, 28 Oct 2022 09:58:25 +0800 Subject: [PATCH] Bell/fix priority (#13667) * debug only Signed-off-by: fishbell * fix model priority with -d AUTO Signed-off-by: fishbell * add tests Signed-off-by: fishbell Signed-off-by: fishbell --- src/plugins/auto/plugin.cpp | 2 ++ src/tests/unit/auto/parse_meta_device_test.cpp | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/plugins/auto/plugin.cpp b/src/plugins/auto/plugin.cpp index 95af6c266f0..e848ad2ba5e 100644 --- a/src/plugins/auto/plugin.cpp +++ b/src/plugins/auto/plugin.cpp @@ -131,6 +131,8 @@ std::vector MultiDeviceInferencePlugin::ParseMetaDevices(cons return ""; }; auto checkPriorityConfig = [&] (const std::string& priString) { + if (priString.empty()) + return false; std::string::size_type pos = 0; std::string::size_type endpos = 0; while ((endpos = priString.find(",", pos)) != std::string::npos) { diff --git a/src/tests/unit/auto/parse_meta_device_test.cpp b/src/tests/unit/auto/parse_meta_device_test.cpp index 5bd51eaaf60..a922e261785 100644 --- a/src/tests/unit/auto/parse_meta_device_test.cpp +++ b/src/tests/unit/auto/parse_meta_device_test.cpp @@ -162,11 +162,10 @@ TEST_P(ParseMetaDeviceTest, ParseMetaDevicesNotWithPriority) { bool throwException; std::tie(priorityDevices, metaDevices, throwException) = this->GetParam(); - EXPECT_CALL(*plugin, ParseMetaDevices(_, _)).Times(1); + EXPECT_CALL(*plugin, ParseMetaDevices(_, _)).Times(1 + !throwException); EXPECT_CALL(*core, GetMetric(_, _, _)).Times(AnyNumber()); EXPECT_CALL(*core, GetConfig(_, _)).Times(AnyNumber()); - EXPECT_CALL(*core, GetAvailableDevices()).Times(1); - EXPECT_CALL(*core, GetSupportedConfig(_, _)).Times(metaDevices.size()); + EXPECT_CALL(*core, GetAvailableDevices()).Times(1 + !throwException); if (throwException) { ASSERT_ANY_THROW(plugin->ParseMetaDevices(priorityDevices, {})); } else { @@ -175,6 +174,11 @@ TEST_P(ParseMetaDeviceTest, ParseMetaDevicesNotWithPriority) { for (unsigned int i = 0 ; i < result.size(); i++) { EXPECT_EQ(result[i].devicePriority, 0); } + auto result2 = plugin->ParseMetaDevices(priorityDevices, {{ov::device::priorities.name(), ""}}); + compare(result2, metaDevices); + for (unsigned int i = 0 ; i < result.size(); i++) { + EXPECT_EQ(result2[i].devicePriority, 0); + } } }