diff --git a/src/plugins/auto/auto_schedule.cpp b/src/plugins/auto/auto_schedule.cpp index 8e5eaf8c648..cc71bdba17e 100644 --- a/src/plugins/auto/auto_schedule.cpp +++ b/src/plugins/auto/auto_schedule.cpp @@ -637,9 +637,13 @@ SoExecNetwork AutoSchedule::WaitFirstNetworkReady() { } } } + std::ostringstream result; //print errMessage + result << "Load network failed, "; for (int i = CONTEXTNUM - 2; i >= 0; i--) { if (_loadContext[i].isEnabled) { + result << _loadContext[i].errMessage.c_str(); + result << "; "; LOG_ERROR_TAG("load failed, %s", _loadContext[i].errMessage.c_str()); } } @@ -654,6 +658,9 @@ SoExecNetwork AutoSchedule::WaitFirstNetworkReady() { execNetwork = _pCTPUTLoadContext[i].executableNetwork; } nLoadSucNums++; + } else { + result << _pCTPUTLoadContext[i].errMessage.c_str(); + result << "; "; } } // one or more devices loaded successfully @@ -661,7 +668,7 @@ SoExecNetwork AutoSchedule::WaitFirstNetworkReady() { return execNetwork; } } - IE_THROW() << GetLogTag() << "load all devices failed"; + IE_THROW() << "[" << GetLogTag() << "] " << result.str(); } void AutoSchedule::WaitActualNetworkReady() const { diff --git a/src/plugins/auto/plugin_config.cpp b/src/plugins/auto/plugin_config.cpp index d35a8917fbb..d9a819aee49 100644 --- a/src/plugins/auto/plugin_config.cpp +++ b/src/plugins/auto/plugin_config.cpp @@ -4,7 +4,6 @@ #include "utils/plugin_config.hpp" namespace MultiDevicePlugin { -const std::set PluginConfig::_availableDevices = {"AUTO", "CPU", "GPU", "TEMPLATE", "NVIDIA", "VPUX", "MULTI", "HETERO", "mock"}; // AUTO will enable the blocklist if // 1.No device priority passed to AUTO/MULTI.(eg. core.compile_model(model, "AUTO", configs);) // 2.No valid device parsed out from device priority (eg. core.compile_model(model, "AUTO:-CPU,-GPU", configs);). diff --git a/src/plugins/auto/utils/plugin_config.hpp b/src/plugins/auto/utils/plugin_config.hpp index 243e1800199..30ab0895796 100644 --- a/src/plugins/auto/utils/plugin_config.hpp +++ b/src/plugins/auto/utils/plugin_config.hpp @@ -234,7 +234,6 @@ private: ov::AnyMap property_mutabilities; // mutability for supported configs/metrics installation std::map property_validators; BaseValidator::Ptr device_property_validator; - static const std::set _availableDevices; static const std::set _deviceBlocklist; }; } // namespace MultiDevicePlugin diff --git a/src/tests/unit/auto/auto_load_network_properties_test.cpp b/src/tests/unit/auto/auto_load_network_properties_test.cpp index 776a160cd42..d8986e8184f 100644 --- a/src/tests/unit/auto/auto_load_network_properties_test.cpp +++ b/src/tests/unit/auto/auto_load_network_properties_test.cpp @@ -29,8 +29,17 @@ using ::testing::Return; using ::testing::ReturnRef; using ::testing::StrEq; using ::testing::Throw; +using ::testing::HasSubstr; using Config = std::map; +#define EXPECT_THROW_WITH_MESSAGE(stmt, etype, whatstring) EXPECT_THROW( \ + try { \ + stmt; \ + } catch (const etype& ex) { \ + EXPECT_THAT(std::string(ex.what()), HasSubstr(whatstring)); \ + throw; \ + } \ + , etype) // define a matcher if all the elements of subMap are contained in the map. MATCHER_P(MapContains, subMap, "Check if all the elements of the subMap are contained in the map.") { if (subMap.empty()) @@ -266,7 +275,60 @@ TEST_P(LoadNetworkWithSecondaryConfigsMockTest, LoadNetworkWithSecondaryConfigsT ASSERT_NO_THROW(plugin->LoadExeNetworkImpl(simpleCnnNetwork, config)); } +using AutoLoadExeNetworkFailedTest = LoadNetworkWithSecondaryConfigsMockTest; +TEST_P(AutoLoadExeNetworkFailedTest, checkLoadFailMassage) { + std::string device; + std::vector targetDevices; + Config config; + std::tie(device, targetDevices, config) = this->GetParam(); + if (device.find("AUTO") != std::string::npos) + plugin->SetName("AUTO"); + if (device.find("MULTI") != std::string::npos) + plugin->SetName("MULTI"); + + ON_CALL(*core, LoadNetwork(::testing::Matcher(_), + ::testing::Matcher(StrEq(CommonTestUtils::DEVICE_GPU)), + ::testing::Matcher(_))) + .WillByDefault(Throw(InferenceEngine::GeneralError{"Mock GPU Load Failed"})); + ON_CALL(*core, LoadNetwork(::testing::Matcher(_), + ::testing::Matcher(StrEq(CommonTestUtils::DEVICE_CPU)), + ::testing::Matcher(_))) + .WillByDefault(Throw(InferenceEngine::GeneralError{"Mock CPU Load Failed"})); + if (device == "AUTO") { + EXPECT_THROW_WITH_MESSAGE(plugin->LoadExeNetworkImpl(simpleCnnNetwork, config), InferenceEngine::Exception, + "[AUTO] Load network failed, GPU:Mock GPU Load Failed; CPU:Mock CPU Load Failed"); + } else if (device == "AUTO:CPU") { + EXPECT_THROW_WITH_MESSAGE(plugin->LoadExeNetworkImpl(simpleCnnNetwork, config), InferenceEngine::Exception, + "[AUTO] Load network failed, CPU:Mock CPU Load Failed"); + } else if (device == "AUTO:GPU") { + EXPECT_THROW_WITH_MESSAGE(plugin->LoadExeNetworkImpl(simpleCnnNetwork, config), InferenceEngine::Exception, + "[AUTO] Load network failed, GPU:Mock GPU Load Failed"); + } else if (device == "MULTI") { + EXPECT_THROW_WITH_MESSAGE(plugin->LoadExeNetworkImpl(simpleCnnNetwork, config), InferenceEngine::Exception, + "[MULTI] Load network failed, GPU:Mock GPU Load Failed; CPU:Mock CPU Load Failed"); + } else if (device == "MULTI:CPU") { + EXPECT_THROW_WITH_MESSAGE(plugin->LoadExeNetworkImpl(simpleCnnNetwork, config), InferenceEngine::Exception, + "[MULTI] Load network failed, CPU:Mock CPU Load Failed"); + } else if (device == "MULTI:GPU") { + EXPECT_THROW_WITH_MESSAGE(plugin->LoadExeNetworkImpl(simpleCnnNetwork, config), InferenceEngine::Exception, + "[MULTI] Load network failed, GPU:Mock GPU Load Failed"); + } +} + INSTANTIATE_TEST_SUITE_P(smoke_AutoMock_LoadNetworkWithSecondaryConfigs, LoadNetworkWithSecondaryConfigsMockTest, ::testing::ValuesIn(LoadNetworkWithSecondaryConfigsMockTest::CreateConfigs()), LoadNetworkWithSecondaryConfigsMockTest::getTestCaseName); + +const std::vector testConfigsAutoLoadFailed = { + ConfigParams{"AUTO", {"CPU", "GPU"}, {{"MULTI_DEVICE_PRIORITIES", "GPU,CPU"}}}, + ConfigParams{"AUTO:CPU", {"CPU"}, {{"MULTI_DEVICE_PRIORITIES", "CPU"}}}, + ConfigParams{"AUTO:GPU", {"GPU"}, {{"MULTI_DEVICE_PRIORITIES", "GPU"}}}, + ConfigParams{"MULTI", {"CPU", "GPU"}, {{"MULTI_DEVICE_PRIORITIES", "GPU,CPU"}}}, + ConfigParams{"MULTI:CPU", {"CPU"}, {{"MULTI_DEVICE_PRIORITIES", "CPU"}}}, + ConfigParams{"MULTI:GPU", {"GPU"}, {{"MULTI_DEVICE_PRIORITIES", "GPU"}}} + }; + +INSTANTIATE_TEST_SUITE_P(smoke_AutoLoadExeNetworkFailedTest, AutoLoadExeNetworkFailedTest, + ::testing::ValuesIn(testConfigsAutoLoadFailed), + AutoLoadExeNetworkFailedTest::getTestCaseName); \ No newline at end of file