OpenVINO给计算设备定义了Device properties
使用下面的范例程序,可以获取目标计算设备的全部属性:
#include <string>
#include <vector>
#include "openvino/openvino.hpp"
using namespace std;
void print_any_value(const ov::Any& value) {
if (value.empty()) {
cout << "EMPTY VALUE" << endl;
}
else {
std::string stringValue = value.as<std::string>();
cout << (stringValue.empty() ? "\"\"" : stringValue) << endl;
}
}
int main(void) {
cout << ov::get_openvino_version() << endl;
// -------- Step 1. Initialize OpenVINO Runtime Core --------
ov::Core core;
// -------- Step 2. Get list of available devices --------
std::vector<std::string> availableDevices = core.get_available_devices();
// -------- Step 3. Query and print supported metrics and config keys --------
cout << "Available devices: " << endl;
for (auto&& device : availableDevices) {
cout << device << endl;
if (device.find("CPU") != string::npos || device.find("GPU") != string::npos) {
// ONLY Query supported properties of CPU or GPU
cout << "\tSUPPORTED_PROPERTIES: " << endl;
auto supported_properties = core.get_property(device, ov::supported_properties);
for (auto&& property : supported_properties) {
if (property != ov::supported_properties.name()) {
cout << "\t\t" << (property.is_mutable() ? "Mutable: " : "Immutable: ") << property << " : "
<< flush;
print_any_value(core.get_property(device, property));
}
}
cout << endl;
}
}
return 0;
}
运行结果如下:
Device properties
网友评论