[AUTO] Show the detailed failure message when AUTO load network failed (#16297)

* Show the detailed failure message when AUTO load network failed

* Add test case

* Update test case to check multi load network failed

* Update test case based master

* RM _availableDevices hard code from AUTO

---------

Co-authored-by: Chen Peter <peter.chen@intel.com>
This commit is contained in:
Wang Wangwang
2023-04-06 15:41:32 +08:00
committed by GitHub
parent b2a64e8c3a
commit 53d9b26e1f
4 changed files with 70 additions and 3 deletions

View File

@@ -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 {

View File

@@ -4,7 +4,6 @@
#include "utils/plugin_config.hpp"
namespace MultiDevicePlugin {
const std::set<std::string> 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);).

View File

@@ -234,7 +234,6 @@ private:
ov::AnyMap property_mutabilities; // mutability for supported configs/metrics installation
std::map<std::string, BaseValidator::Ptr> property_validators;
BaseValidator::Ptr device_property_validator;
static const std::set<std::string> _availableDevices;
static const std::set<std::string> _deviceBlocklist;
};
} // namespace MultiDevicePlugin

View File

@@ -29,8 +29,17 @@ using ::testing::Return;
using ::testing::ReturnRef;
using ::testing::StrEq;
using ::testing::Throw;
using ::testing::HasSubstr;
using Config = std::map<std::string, std::string>;
#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<std::string> 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<const InferenceEngine::CNNNetwork&>(_),
::testing::Matcher<const std::string&>(StrEq(CommonTestUtils::DEVICE_GPU)),
::testing::Matcher<const Config&>(_)))
.WillByDefault(Throw(InferenceEngine::GeneralError{"Mock GPU Load Failed"}));
ON_CALL(*core, LoadNetwork(::testing::Matcher<const InferenceEngine::CNNNetwork&>(_),
::testing::Matcher<const std::string&>(StrEq(CommonTestUtils::DEVICE_CPU)),
::testing::Matcher<const Config&>(_)))
.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<ConfigParams> 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);