[AUTO plugin] MULTI_DEVICE_PRIORITIES doesn't return device list by priority order from high to low (#14754)
* 1. Correct the device list by priority order from high to low. 2. Remove GNA, CUDA, HPU, HDDL, NVIDIA from device list supported by AUTO/MULTI. Signed-off-by: Wang, Yang <yang4.wang@intel.com> * Filter out supported device when not specify the candidate device for AUTO plugin. * Add Debug MSG * Update. * Update AUTO mock test cases. * Update. * Update. * Update code style. --------- Signed-off-by: Wang, Yang <yang4.wang@intel.com> Co-authored-by: Chen Peter <peter.chen@intel.com>
This commit is contained in:
1 parent
4ba30a4afa
commit
3bfd07d535
12 files changed
+66
-40
No files matched your search
@@ -418,6 +418,13 @@ IExecutableNetworkInternal::Ptr MultiDeviceInferencePlugin::LoadNetworkImpl(cons
|
||||
}
|
||||
// reset the strDevices to support devices
|
||||
strDevices = "";
|
||||
// calling GetValidDevices() to get a prioritized list of devices
|
||||
auto devicesWithPriority = GetValidDevice(supportDevices, networkPrecision);
|
||||
for (auto iter = devicesWithPriority.begin(); iter != devicesWithPriority.end(); iter++) {
|
||||
strDevices += iter->deviceName;
|
||||
strDevices += ",";
|
||||
}
|
||||
strDevices.pop_back();
|
||||
for (auto iter = supportDevices.begin(); iter != supportDevices.end(); iter++) {
|
||||
auto& configs = iter->config;
|
||||
for (auto& config : configs) {
|
||||
@@ -432,8 +439,6 @@ IExecutableNetworkInternal::Ptr MultiDeviceInferencePlugin::LoadNetworkImpl(cons
|
||||
if (config.find(CONFIG_KEY(AUTO_BATCH_TIMEOUT)) != config.end())
|
||||
insertPropToConfig(CONFIG_KEY(AUTO_BATCH_TIMEOUT), iter->deviceName, configs);
|
||||
insertPropToConfig(CONFIG_KEY(CACHE_DIR), iter->deviceName, configs);
|
||||
strDevices += iter->deviceName;
|
||||
strDevices += ((iter + 1) == supportDevices.end()) ? "" : ",";
|
||||
LOG_INFO_TAG("device:%s, priority:%ld", iter->deviceName.c_str(), iter->devicePriority);
|
||||
}
|
||||
autoSContext->_modelPath = clonedModelPath;
|
||||
@@ -813,9 +818,14 @@ std::string MultiDeviceInferencePlugin::GetDeviceList(const std::map<std::string
|
||||
auto deviceListConfig = config.find(MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES);
|
||||
if (deviceListConfig->second.empty()) {
|
||||
for (auto&& device : deviceList) {
|
||||
allDevices += device;
|
||||
allDevices += ((device == deviceList[deviceList.size()-1]) ? "" : ",");
|
||||
// filter out the supported devices
|
||||
if (!_pluginConfig.isSupportedDevice(device))
|
||||
continue;
|
||||
allDevices += device + ",";
|
||||
}
|
||||
// remove the last ',' if exist
|
||||
if (allDevices.back() == ',')
|
||||
allDevices.pop_back();
|
||||
} else {
|
||||
auto priorities = deviceListConfig->second;
|
||||
// parsing the string and splitting the comma-separated tokens
|
||||
|
||||
@@ -192,37 +192,37 @@ struct PluginConfig {
|
||||
_keyConfigMap.clear();
|
||||
adjustKeyMapValues();
|
||||
}
|
||||
bool isSupportedDevice(const std::string& deviceName) const {
|
||||
if (deviceName.empty())
|
||||
return false;
|
||||
auto realDevName = deviceName[0] != '-' ? deviceName : deviceName.substr(1);
|
||||
if (realDevName.empty()) {
|
||||
return false;
|
||||
}
|
||||
realDevName = DeviceIDParser(realDevName).getDeviceName();
|
||||
std::string::size_type realEndPos = 0;
|
||||
if ((realEndPos = realDevName.find('(')) != std::string::npos) {
|
||||
realDevName = realDevName.substr(0, realEndPos);
|
||||
}
|
||||
if (_availableDevices.end() == std::find(_availableDevices.begin(), _availableDevices.end(), realDevName)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
std::vector<std::string> ParsePrioritiesDevices(const std::string& priorities, const char separator = ',') const {
|
||||
std::vector<std::string> devices;
|
||||
std::string::size_type pos = 0;
|
||||
std::string::size_type endpos = 0;
|
||||
auto isAvailableDevice = [&](std::string& deviceName) -> bool {
|
||||
if (deviceName.empty())
|
||||
return false;
|
||||
auto realDevName = deviceName[0] != '-' ? deviceName : deviceName.substr(1);
|
||||
if (realDevName.empty()) {
|
||||
return false;
|
||||
}
|
||||
realDevName = DeviceIDParser(realDevName).getDeviceName();
|
||||
std::string::size_type realEndPos = 0;
|
||||
if ((realEndPos = realDevName.find('(')) != std::string::npos) {
|
||||
realDevName = realDevName.substr(0, realEndPos);
|
||||
}
|
||||
if (_availableDevices.end() == std::find(_availableDevices.begin(), _availableDevices.end(), realDevName)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
while ((endpos = priorities.find(separator, pos)) != std::string::npos) {
|
||||
auto subStr = priorities.substr(pos, endpos - pos);
|
||||
if (!isAvailableDevice(subStr)) {
|
||||
if (!isSupportedDevice(subStr)) {
|
||||
IE_THROW() << "Unavailable device name: " << subStr;
|
||||
}
|
||||
devices.push_back(subStr);
|
||||
pos = endpos + 1;
|
||||
}
|
||||
auto subStr = priorities.substr(pos, priorities.length() - pos);
|
||||
if (!isAvailableDevice(subStr)) {
|
||||
if (!isSupportedDevice(subStr)) {
|
||||
IE_THROW() << "Unavailable device name: " << subStr;
|
||||
}
|
||||
devices.push_back(subStr);
|
||||
@@ -289,17 +289,7 @@ struct PluginConfig {
|
||||
bool _isBatchConfigSet = false;
|
||||
std::map<std::string, std::string> _passThroughConfig;
|
||||
std::map<std::string, std::string> _keyConfigMap;
|
||||
const std::set<std::string> _availableDevices = {"AUTO",
|
||||
"CPU",
|
||||
"GPU",
|
||||
"GNA",
|
||||
"TEMPLATE",
|
||||
"VPUX",
|
||||
"MULTI",
|
||||
"HETERO",
|
||||
"CUDA",
|
||||
"NVIDIA",
|
||||
"HPU_GOYA",
|
||||
"mock"};
|
||||
const std::set<std::string> _availableDevices =
|
||||
{"AUTO", "CPU", "GPU", "TEMPLATE", "MYRIAD", "VPUX", "MULTI", "HETERO", "mock"};
|
||||
};
|
||||
} // namespace MultiDevicePlugin
|
||||
+1
-1
@@ -26,7 +26,7 @@ INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_IEClassExecutableNetworkGetMetricTest,
|
||||
// TODO: this metric is not supported by the plugin
|
||||
INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_IEClassExecutableNetworkGetMetricTest,
|
||||
IEClassExecutableNetworkGetMetricTest_NETWORK_NAME,
|
||||
::testing::Values("GNA", "MULTI:GNA", "HETERO:GNA"));
|
||||
::testing::Values("GNA", /* "MULTI:GNA", */ "HETERO:GNA"));
|
||||
|
||||
// TODO: Convolution with 3D input is not supported on GNA
|
||||
INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_IEClassExecutableNetworkGetMetricTest,
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_OVClassExecutableNetworkGetMetricTest,
|
||||
// TODO: this metric is not supported by the plugin
|
||||
INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_OVClassExecutableNetworkGetMetricTest,
|
||||
OVClassExecutableNetworkGetMetricTest_NETWORK_NAME,
|
||||
::testing::Values("GNA", "MULTI:GNA", "HETERO:GNA"));
|
||||
::testing::Values("GNA", /* "MULTI:GNA", */ "HETERO:GNA"));
|
||||
|
||||
// TODO: Convolution with 3D input is not supported on GNA
|
||||
INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_OVClassExecutableNetworkGetMetricTest,
|
||||
|
||||
+1
-3
@@ -8,11 +8,9 @@ namespace {
|
||||
Params params[] = {
|
||||
std::tuple<Device, Config>{CommonTestUtils::DEVICE_GNA, {{CONFIG_KEY(PERF_COUNT), CONFIG_VALUE(YES)}}},
|
||||
std::tuple<Device, Config>{CommonTestUtils::DEVICE_HETERO, {{"TARGET_FALLBACK", CommonTestUtils::DEVICE_GNA}}},
|
||||
std::tuple<Device, Config>{CommonTestUtils::DEVICE_MULTI,
|
||||
{{MULTI_CONFIG_KEY(DEVICE_PRIORITIES), CommonTestUtils::DEVICE_GNA}}},
|
||||
};
|
||||
// TODO: Consider to append params[1] after issue *-45658 resolved
|
||||
std::vector<std::tuple<Device, Config>> paramsWithIterations{params[0], params[2]};
|
||||
std::vector<std::tuple<Device, Config>> paramsWithIterations{params[0]};
|
||||
} // namespace
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(GNA, CoreThreadingTests, testing::ValuesIn(params), CoreThreadingTests::getTestCaseName);
|
||||
|
||||
@@ -97,5 +97,6 @@ std::vector<std::string> disabledTestPatterns() {
|
||||
R"(.*CachingSupportCase.*LoadNet.*(Bias|Split|Concat|KSO|SingleConv).*)",
|
||||
R"(.*CachingSupportCase.*LoadNet.*(ConvPoolRelu|TIwithLSTMcell1)_f32_batch2.*)",
|
||||
R"(.*IEClassLoadNetworkTest.*LoadNetwork(HETERO|MULTI|WithDeviceIDNoThrow|WithInvalidDeviceIDThrows).*)",
|
||||
R"(.*smoke_Multi_BehaviorTests.*)",
|
||||
};
|
||||
}
|
||||
@@ -162,6 +162,11 @@ TEST_P(AutoReleaseHelperTest, releaseResource) {
|
||||
metaDevices = {{CommonTestUtils::DEVICE_CPU, {}, -1}, {CommonTestUtils::DEVICE_GPU, {}, -1}};
|
||||
DeviceInformation devInfo;
|
||||
ON_CALL(*plugin, ParseMetaDevices(_, _)).WillByDefault(Return(metaDevices));
|
||||
ON_CALL(*plugin, GetValidDevice)
|
||||
.WillByDefault([this](const std::vector<DeviceInformation>& metaDevices, const std::string& netPrecision) {
|
||||
std::list<DeviceInformation> devices(metaDevices.begin(), metaDevices.end());
|
||||
return devices;
|
||||
});
|
||||
ON_CALL(*plugin, SelectDevice(Property(&std::vector<DeviceInformation>::size, Eq(2)), _, _))
|
||||
.WillByDefault(Return(metaDevices[1]));
|
||||
ON_CALL(*plugin, SelectDevice(Property(&std::vector<DeviceInformation>::size, Eq(1)), _, _))
|
||||
|
||||
@@ -225,6 +225,11 @@ TEST_P(AutoLoadFailedTest, LoadCNNetWork) {
|
||||
devicesStr += ((++iter) == deviceConfigs.end()) ? "" : ",";
|
||||
}
|
||||
ON_CALL(*plugin, ParseMetaDevices(_, _)).WillByDefault(Return(metaDevices));
|
||||
ON_CALL(*plugin, GetValidDevice)
|
||||
.WillByDefault([this](const std::vector<DeviceInformation>& metaDevices, const std::string& netPrecision) {
|
||||
std::list<DeviceInformation> devices(metaDevices.begin(), metaDevices.end());
|
||||
return devices;
|
||||
});
|
||||
config.insert({InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES , devicesStr});
|
||||
// if set this parameter true, the second selecting call will thrown exception,
|
||||
// if there is only one device, it will thrown exception at the first call
|
||||
|
||||
@@ -215,6 +215,11 @@ TEST_P(ExecNetworkGetMetric, OPTIMAL_NUMBER_OF_INFER_REQUESTS) {
|
||||
}
|
||||
ON_CALL(*plugin, SelectDevice(_, _, _)).WillByDefault(Return(metaDevices[1]));
|
||||
ON_CALL(*plugin, ParseMetaDevices(_, _)).WillByDefault(Return(metaDevices));
|
||||
ON_CALL(*plugin, GetValidDevice)
|
||||
.WillByDefault([this](const std::vector<DeviceInformation>& metaDevices, const std::string& netPrecision) {
|
||||
std::list<DeviceInformation> devices(metaDevices.begin(), metaDevices.end());
|
||||
return devices;
|
||||
});
|
||||
EXPECT_CALL(*plugin, ParseMetaDevices(_, _)).Times(1);
|
||||
EXPECT_CALL(*plugin, SelectDevice(_, _, _)).Times(1);
|
||||
|
||||
|
||||
@@ -96,6 +96,10 @@ public:
|
||||
const std::string& netPrecision, unsigned int Priority) {
|
||||
return plugin->MultiDeviceInferencePlugin::SelectDevice(metaDevices, netPrecision, Priority);
|
||||
});
|
||||
ON_CALL(*plugin, GetValidDevice)
|
||||
.WillByDefault([this](const std::vector<DeviceInformation>& metaDevices, const std::string& netPrecision) {
|
||||
return plugin->MultiDeviceInferencePlugin::GetValidDevice(metaDevices, netPrecision);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@ namespace MockMultiDevice {
|
||||
class MockMultiDeviceInferencePlugin : public MultiDeviceInferencePlugin {
|
||||
public:
|
||||
MOCK_METHOD((std::string), GetDeviceList, ((const std::map<std::string, std::string>&)), (const, override));
|
||||
MOCK_METHOD((std::list<DeviceInformation>),
|
||||
GetValidDevice,
|
||||
((const std::vector<DeviceInformation>&), const std::string&),
|
||||
(override));
|
||||
MOCK_METHOD(DeviceInformation, SelectDevice, ((const std::vector<DeviceInformation>&),
|
||||
const std::string&, unsigned int), (override));
|
||||
MOCK_METHOD((std::vector<DeviceInformation>), ParseMetaDevices,
|
||||
|
||||
@@ -252,6 +252,10 @@ public:
|
||||
const std::string& netPrecision, unsigned int priority) {
|
||||
return plugin->MultiDeviceInferencePlugin::SelectDevice(metaDevices, netPrecision, priority);
|
||||
});
|
||||
ON_CALL(*plugin, GetValidDevice)
|
||||
.WillByDefault([this](const std::vector<DeviceInformation>& metaDevices, const std::string& netPrecision) {
|
||||
return plugin->MultiDeviceInferencePlugin::GetValidDevice(metaDevices, netPrecision);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user