Added GetAvailableDevices for AUTO device (#5377)
* Added GetAvailableDevices for AUTO device * Fixed tests compilation
This commit is contained in:
parent
05cae2714f
commit
0337b055db
@ -238,7 +238,7 @@ public:
|
||||
* @brief Returns devices available for neural networks inference
|
||||
*
|
||||
* @return A vector of devices. The devices are returned as { CPU, FPGA.0, FPGA.1, MYRIAD }
|
||||
If there more than one device of specific type, they are enumerated with .# suffix.
|
||||
* If there more than one device of specific type, they are enumerated with .# suffix.
|
||||
*/
|
||||
std::vector<std::string> GetAvailableDevices() const;
|
||||
|
||||
|
@ -591,6 +591,43 @@ public:
|
||||
return copyParameterValue(GetCPPPluginByName(parsed._deviceName).GetMetric(name, parsed._config));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns devices available for neural networks inference
|
||||
*
|
||||
* @return A vector of devices. The devices are returned as { CPU, FPGA.0, FPGA.1, MYRIAD }
|
||||
* If there more than one device of specific type, they are enumerated with .# suffix.
|
||||
*/
|
||||
std::vector<std::string> GetAvailableDevices() const override {
|
||||
std::vector<std::string> devices;
|
||||
const std::string propertyName = METRIC_KEY(AVAILABLE_DEVICES);
|
||||
|
||||
for (auto&& deviceName : GetListOfDevicesInRegistry()) {
|
||||
std::vector<std::string> devicesIDs;
|
||||
try {
|
||||
const Parameter p = GetMetric(deviceName, propertyName);
|
||||
devicesIDs = p.as<std::vector<std::string>>();
|
||||
} catch (Exception&) {
|
||||
// plugin is not created by e.g. invalid env
|
||||
} catch (const std::exception& ex) {
|
||||
IE_THROW() << "An exception is thrown while trying to create the " << deviceName
|
||||
<< " device and call GetMetric: " << ex.what();
|
||||
} catch (...) {
|
||||
IE_THROW() << "Unknown exception is thrown while trying to create the " << deviceName
|
||||
<< " device and call GetMetric";
|
||||
}
|
||||
|
||||
if (devicesIDs.size() > 1) {
|
||||
for (auto&& deviceID : devicesIDs) {
|
||||
devices.push_back(deviceName + '.' + deviceID);
|
||||
}
|
||||
} else if (!devicesIDs.empty()) {
|
||||
devices.push_back(deviceName);
|
||||
}
|
||||
}
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns reference to CPP plugin wrapper by a device name
|
||||
* @param deviceName A name of device
|
||||
@ -1007,35 +1044,7 @@ Parameter Core::GetMetric(const std::string& deviceName, const std::string& name
|
||||
}
|
||||
|
||||
std::vector<std::string> Core::GetAvailableDevices() const {
|
||||
std::vector<std::string> devices;
|
||||
|
||||
std::string propertyName = METRIC_KEY(AVAILABLE_DEVICES);
|
||||
|
||||
for (auto&& deviceName : _impl->GetListOfDevicesInRegistry()) {
|
||||
std::vector<std::string> devicesIDs;
|
||||
try {
|
||||
Parameter p = GetMetric(deviceName, propertyName);
|
||||
devicesIDs = p.as<std::vector<std::string>>();
|
||||
} catch (Exception&) {
|
||||
// plugin is not created by e.g. invalid env
|
||||
} catch (const std::exception& ex) {
|
||||
IE_THROW() << "An exception is thrown while trying to create the " << deviceName
|
||||
<< " device and call GetMetric: " << ex.what();
|
||||
} catch (...) {
|
||||
IE_THROW() << "Unknown exception is thrown while trying to create the " << deviceName
|
||||
<< " device and call GetMetric";
|
||||
}
|
||||
|
||||
if (devicesIDs.size() > 1) {
|
||||
for (auto&& deviceID : devicesIDs) {
|
||||
devices.push_back(deviceName + '.' + deviceID);
|
||||
}
|
||||
} else if (!devicesIDs.empty()) {
|
||||
devices.push_back(deviceName);
|
||||
}
|
||||
}
|
||||
|
||||
return devices;
|
||||
return _impl->GetAvailableDevices();
|
||||
}
|
||||
|
||||
void Core::RegisterPlugin(const std::string& pluginName, const std::string& deviceName) {
|
||||
|
@ -100,6 +100,14 @@ public:
|
||||
*/
|
||||
virtual Parameter GetMetric(const std::string& deviceName, const std::string& name) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns devices available for neural networks inference
|
||||
*
|
||||
* @return A vector of devices. The devices are returned as { CPU, FPGA.0, FPGA.1, MYRIAD }
|
||||
* If there more than one device of specific type, they are enumerated with .# suffix.
|
||||
*/
|
||||
virtual std::vector<std::string> GetAvailableDevices() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Default virtual destructor
|
||||
*/
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
const InferenceEngine::CNNNetwork&, const std::string&, const std::map<std::string, std::string>&));
|
||||
|
||||
MOCK_QUALIFIED_METHOD2(GetMetric, const, InferenceEngine::Parameter(const std::string&, const std::string&));
|
||||
MOCK_QUALIFIED_METHOD0(GetAvailableDevices, const, std::vector<std::string>());
|
||||
|
||||
~MockICore() = default;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user