[AUTOPLUGIN] not select if only one device (#9730)
* if only one Device, not select Signed-off-by: Hu, Yuan2 <yuan2.hu@intel.com> * modify test case to match logic Signed-off-by: Hu, Yuan2 <yuan2.hu@intel.com>
This commit is contained in:
@@ -455,23 +455,27 @@ DeviceInformation MultiDeviceInferencePlugin::SelectDevice(const std::vector<Dev
|
||||
|
||||
std::list<DeviceInformation> validDevices;
|
||||
|
||||
auto selectSupportDev = [this, &devices, &validDevices](const std::string& networkPrecision) {
|
||||
for (auto iter = devices.begin(); iter != devices.end();) {
|
||||
std::vector<std::string> capability = GetCore()->GetMetric(iter->deviceName, METRIC_KEY(OPTIMIZATION_CAPABILITIES));
|
||||
auto supportNetwork = std::find(capability.begin(), capability.end(), (networkPrecision));
|
||||
if (supportNetwork != capability.end()) {
|
||||
validDevices.push_back(std::move(*iter));
|
||||
devices.erase(iter++);
|
||||
continue;
|
||||
if (metaDevices.size() > 1) {
|
||||
auto selectSupportDev = [this, &devices, &validDevices](const std::string& networkPrecision) {
|
||||
for (auto iter = devices.begin(); iter != devices.end();) {
|
||||
std::vector<std::string> capability = GetCore()->GetMetric(iter->deviceName, METRIC_KEY(OPTIMIZATION_CAPABILITIES));
|
||||
auto supportNetwork = std::find(capability.begin(), capability.end(), (networkPrecision));
|
||||
if (supportNetwork != capability.end()) {
|
||||
validDevices.push_back(std::move(*iter));
|
||||
devices.erase(iter++);
|
||||
continue;
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
iter++;
|
||||
};
|
||||
selectSupportDev(networkPrecision);
|
||||
// If network is FP32, continue to collect the device support FP16 but not support FP32.
|
||||
if (networkPrecision == "FP32") {
|
||||
const std::string f16 = "FP16";
|
||||
selectSupportDev(f16);
|
||||
}
|
||||
};
|
||||
selectSupportDev(networkPrecision);
|
||||
// If network is FP32, continue to collect the device support FP16 but not support FP32.
|
||||
if (networkPrecision == "FP32") {
|
||||
const std::string f16 = "FP16";
|
||||
selectSupportDev(f16);
|
||||
} else {
|
||||
validDevices.push_back(metaDevices[0]);
|
||||
}
|
||||
|
||||
if (validDevices.empty()) {
|
||||
|
||||
@@ -106,14 +106,21 @@ public:
|
||||
auto& devicesInfo = devicesMap[netPrecision];
|
||||
bool find = false;
|
||||
DeviceInformation expect;
|
||||
for (auto& item : devicesInfo) {
|
||||
auto device = std::find_if(metaDevices.begin(), metaDevices.end(),
|
||||
[&item](const DeviceInformation& d)->bool{return d.uniqueName == item.uniqueName;});
|
||||
if (device != metaDevices.end()) {
|
||||
find = true;
|
||||
expect = item;
|
||||
break;
|
||||
if (metaDevices.size() > 1) {
|
||||
for (auto& item : devicesInfo) {
|
||||
auto device = std::find_if(metaDevices.begin(), metaDevices.end(),
|
||||
[&item](const DeviceInformation& d)->bool{return d.uniqueName == item.uniqueName;});
|
||||
if (device != metaDevices.end()) {
|
||||
find = true;
|
||||
expect = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (metaDevices.size() == 1) {
|
||||
expect = metaDevices[0];
|
||||
find = true;
|
||||
} else {
|
||||
find = false;
|
||||
}
|
||||
testConfigs.push_back(std::make_tuple(netPrecision, metaDevices, expect, !find));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user