1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * @brief This header file contains aspects of working on different devices like CPU, GEN, FPGA, etc.
15 #include <ie_common.h>
17 namespace InferenceEngine {
21 * @brief Describes known device types
23 enum class TargetDevice : uint8_t {
37 * @brief Describes the relationship between the enumerator type and the actual device's name
39 class TargetDeviceInfo {
43 Info(TargetDevice device, std::string name) : device(device), name(name){}
45 static const std::vector<Info> & getAll() {
46 #define DECL_DEVICE(device_type) {TargetDevice::e##device_type, #device_type}
48 static std::vector<Info> g_allDeviceInfos = {
50 DECL_DEVICE(Balanced),
61 return g_allDeviceInfos;
65 static TargetDevice fromStr(const std::string &deviceName) {
66 static std::map<std::string, InferenceEngine::TargetDevice> deviceFromNameMap = {
67 { "CPU", InferenceEngine::TargetDevice::eCPU },
68 { "GPU", InferenceEngine::TargetDevice::eGPU },
69 { "FPGA", InferenceEngine::TargetDevice::eFPGA },
70 { "MYRIAD", InferenceEngine::TargetDevice::eMYRIAD },
71 { "HDDL", InferenceEngine::TargetDevice::eHDDL },
72 { "GNA", InferenceEngine::TargetDevice::eGNA },
73 { "BALANCED", InferenceEngine::TargetDevice::eBalanced },
74 { "HETERO", InferenceEngine::TargetDevice::eHETERO },
75 { "KMB", InferenceEngine::TargetDevice::eKMB }
77 auto val = deviceFromNameMap.find(deviceName);
78 return val != deviceFromNameMap.end() ? val->second : InferenceEngine::TargetDevice::eDefault;
81 static const char * name(TargetDevice device) {
82 auto res = std::find_if(getAll().cbegin(), getAll().cend(), [&](const Info & info){
83 return device == info.device;
85 if (res == getAll().cend()) {
86 return "Unknown device";
88 return res->name.c_str();
93 * @brief Returns the device name
94 * @param device Instance of TargetDevice
95 * @return A c-string with the name
97 inline const char *getDeviceName(TargetDevice device) {
98 return TargetDeviceInfo::name(device);
102 * @struct FindPluginRequest
103 * @brief Defines a message that contains the TargetDevice object to find a plugin for
105 struct FindPluginRequest {
107 * @brief object of TargetDevice to find a plugin for
113 * @struct FindPluginResponse
114 * @brief Defines a message that contains a list of appropriate plugin names
116 struct FindPluginResponse {
118 * @brief A list of appropriate plugin names
120 std::vector<std::string> names;
124 * @brief Finds an appropriate plugin for requested target device
125 * @param req A requested target device
126 * @param result The results of the request
127 * @param resp The response message description
128 * @return A response message
130 FindPluginResponse findPlugin(const FindPluginRequest &req);
132 INFERENCE_ENGINE_API(StatusCode) findPlugin(const FindPluginRequest &req, FindPluginResponse &result,
133 ResponseDesc *resp) noexcept;
134 } // namespace InferenceEngine