// Copyright (C) 2018-2020 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include #include #include #include #include #include #include #include #include using namespace InferenceEngine; namespace { template std::ostream & operator << (std::ostream & stream, const std::vector & v) { stream << "[ "; for (auto && value : v) stream << value << " "; return stream << "]"; } void printParameterValue(const Parameter & value) { if (value.is()) { std::cout << std::boolalpha << value.as() << std::noboolalpha << std::endl; } else if (value.is()) { std::cout << value.as() << std::endl; } else if (value.is()) { std::cout << value.as() << std::endl; } else if (value.is()) { std::cout << value.as() << std::endl; } else if (value.is()) { std::string stringValue = value.as(); std::cout << (stringValue.empty() ? "\"\"" : stringValue) << std::endl; } else if (value.is >()) { std::cout << value.as >() << std::endl; } else if (value.is >()) { std::cout << value.as >() << std::endl; } else if (value.is >()) { std::cout << value.as >() << std::endl; } else if (value.is >()) { std::cout << value.as >() << std::endl; } else if (value.is >()) { auto values = value.as >(); std::cout << "{ "; std::cout << std::get<0>(values) << ", "; std::cout << std::get<1>(values) << ", "; std::cout << std::get<2>(values); std::cout << " }"; std::cout << std::endl; } else if (value.is >()) { auto values = value.as >(); std::cout << "{ "; std::cout << std::get<0>(values) << ", "; std::cout << std::get<1>(values); std::cout << " }"; std::cout << std::endl; } else { std::cout << "UNSUPPORTED TYPE" << std::endl; } } } // namespace int main(int argc, char *argv[]) { try { // ------------------------------ Parsing and validation of input args --------------------------------- if (argc != 1) { std::cout << "Usage : ./hello_query_device" << std::endl; return EXIT_FAILURE; } // --------------------------- 1. Load Inference engine instance ------------------------------------- Core ie; // --------------------------- 2. Get list of available devices ------------------------------------- std::vector availableDevices = ie.GetAvailableDevices(); // --------------------------- 3. Query and print supported metrics and config keys-------------------- std::cout << "Available devices: " << std::endl; for (auto && device : availableDevices) { std::cout << "\tDevice: " << device << std::endl; std::cout << "\tMetrics: " << std::endl; std::vector supportedMetrics = ie.GetMetric(device, METRIC_KEY(SUPPORTED_METRICS)); for (auto && metricName : supportedMetrics) { if (metricName != METRIC_KEY(AVAILABLE_DEVICES)) { std::cout << "\t\t" << metricName << " : " << std::flush; printParameterValue(ie.GetMetric(device, metricName)); } } if (std::find(supportedMetrics.begin(), supportedMetrics.end(), METRIC_KEY(SUPPORTED_CONFIG_KEYS)) != supportedMetrics.end()) { std::cout << "\tDefault values for device configuration keys: " << std::endl; std::vector supportedConfigKeys = ie.GetMetric(device, METRIC_KEY(SUPPORTED_CONFIG_KEYS)); for (auto && configKey : supportedConfigKeys) { std::cout << "\t\t" << configKey << " : " << std::flush; printParameterValue(ie.GetConfig(device, configKey)); } } std::cout << std::endl; } } catch (const std::exception & ex) { std::cerr << ex.what() << std::endl; return EXIT_FAILURE; } return EXIT_SUCCESS; }