ie_device.hpp
Go to the documentation of this file.
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 /**
6  * @brief This header file contains aspects of working on different devices like CPU, GEN, FPGA, etc.
7  * @file ie_device.hpp
8  */
9 #pragma once
10 
11 #include <string>
12 #include <vector>
13 #include <map>
14 #include <ie_api.h>
15 #include <ie_common.h>
16 
17 namespace InferenceEngine {
18 
19 /**
20  * @deprecated Deprecated since the enum is not scalable for 3rd party plugins / devices. All devices are managed by InferenceEngine::Core
21  * @enum TargetDevice
22  * @brief Describes known device types
23  */
24 enum class TargetDevice : uint8_t {
25  eDefault = 0,
26  eBalanced = 1,
27  eCPU = 2,
28  eGPU = 3,
29  eFPGA = 4,
30  eMYRIAD = 5,
31  eHDDL = 6,
32  eGNA = 7,
33  eHETERO = 8,
34  eMULTI = 10,
35 };
36 
37 /**
38  * @deprecated Deprecated since InferenceEngine::TargetDevice is deprecated
39  * @brief Describes the relationship between the enumerator type and the actual device's name
40  */
41 class INFERENCE_ENGINE_DEPRECATED TargetDeviceInfo {
42  struct Info {
43  TargetDevice device;
44  std::string name;
45  Info(TargetDevice device, std::string name) : device(device), name(name){}
46  };
47 
48  static const std::vector<Info> & getAll() {
49 #define DECL_DEVICE(device_type) {TargetDevice::e##device_type, #device_type}
50 
51  static std::vector<Info> g_allDeviceInfos = {
52  DECL_DEVICE(Default),
53  DECL_DEVICE(Balanced),
54  DECL_DEVICE(CPU),
55  DECL_DEVICE(GPU),
56  DECL_DEVICE(FPGA),
57  DECL_DEVICE(MYRIAD),
58  DECL_DEVICE(HDDL),
59  DECL_DEVICE(GNA),
60  DECL_DEVICE(HETERO),
61  DECL_DEVICE(MULTI)
62  };
63 #undef DECLARE
64  return g_allDeviceInfos;
65  }
66 
67  public:
68  /**
69  * @deprecated Deprecated since InferenceEngine::TargetDevice is deprecated
70  * @brief Converts string representation of device to InferenceEngine::TargetDevice enum value
71  * @param deviceName A string representation of a device name
72  * @return An instance of InferenceEngine::TargetDevice
73  */
74  INFERENCE_ENGINE_DEPRECATED
75  static TargetDevice fromStr(const std::string &deviceName) {
76  static std::map<std::string, InferenceEngine::TargetDevice> deviceFromNameMap = {
77  { "CPU", InferenceEngine::TargetDevice::eCPU },
78  { "GPU", InferenceEngine::TargetDevice::eGPU },
79  { "FPGA", InferenceEngine::TargetDevice::eFPGA },
80  { "MYRIAD", InferenceEngine::TargetDevice::eMYRIAD },
81  { "HDDL", InferenceEngine::TargetDevice::eHDDL },
82  { "GNA", InferenceEngine::TargetDevice::eGNA },
83  { "BALANCED", InferenceEngine::TargetDevice::eBalanced },
84  { "HETERO", InferenceEngine::TargetDevice::eHETERO },
85  { "MULTI", InferenceEngine::TargetDevice::eMULTI}
86  };
87  auto val = deviceFromNameMap.find(deviceName);
88  return val != deviceFromNameMap.end() ? val->second : InferenceEngine::TargetDevice::eDefault;
89  }
90 
91  /**
92  * @deprecated Deprecated since InferenceEngine::TargetDevice is deprecated
93  * @brief Converts an instance of InferenceEngine::TargetDevice to string representation
94  * @param device Instance of InferenceEngine::TargetDevice
95  * @return A c-string with the name
96  */
97  INFERENCE_ENGINE_DEPRECATED
98  static const char * name(TargetDevice device) {
99  IE_SUPPRESS_DEPRECATED_START
100  auto res = std::find_if(getAll().cbegin(), getAll().cend(), [&](const Info & info){
101  return device == info.device;
102  });
103  if (res == getAll().cend()) {
104  return "Unknown device";
105  }
106  IE_SUPPRESS_DEPRECATED_END
107  return res->name.c_str();
108  }
109 };
110 
111 /**
112  * @deprecated Deprecated since InferenceEngine::TargetDevice is deprecated
113  * @brief Returns the device name
114  * @param device Instance of InferenceEngine::TargetDevice
115  * @return A c-string with the name
116  */
117 INFERENCE_ENGINE_DEPRECATED
118 inline const char *getDeviceName(TargetDevice device) {
119  IE_SUPPRESS_DEPRECATED_START
120  return TargetDeviceInfo::name(device);
121  IE_SUPPRESS_DEPRECATED_END
122 }
123 
124 /**
125  * @deprecated Deprecated since InferenceEngine::TargetDevice is deprecated
126  * @struct FindPluginRequest
127  * @brief Defines a message that contains the InferenceEngine::TargetDevice object to find a plugin for
128  */
129 struct INFERENCE_ENGINE_DEPRECATED FindPluginRequest {
130  /**
131  * @brief object of InferenceEngine::TargetDevice to find a plugin for
132  */
134 };
135 
136 /**
137  * @deprecated Deprecated since InferenceEngine::TargetDevice is deprecated
138  * @struct FindPluginResponse
139  * @brief Defines a message that contains a list of appropriate plugin names
140  */
141 struct INFERENCE_ENGINE_DEPRECATED FindPluginResponse {
142  /**
143  * @brief A list of appropriate plugin names
144  */
145  std::vector<std::string> names;
146 };
147 
148 IE_SUPPRESS_DEPRECATED_START
149 
150 /**
151  * @deprecated Deprecated since InferenceEngine::TargetDevice is deprecated
152  * @brief Finds an appropriate plugin for requested target device
153  * @param req A requested target device
154  * @return A response object
155  */
157 
158 /**
159  * @deprecated Deprecated since InferenceEngine::TargetDevice is deprecated
160  * @brief Finds an appropriate plugin for requested target device
161  * @param req A requested target device
162  * @param result The results of the request
163  * @param resp The response message description
164  * @return A status code
165  */
166 INFERENCE_ENGINE_API(StatusCode) findPlugin(const FindPluginRequest &req, FindPluginResponse &result,
167  ResponseDesc *resp) noexcept;
168 
169 IE_SUPPRESS_DEPRECATED_END
170 
171 } // namespace InferenceEngine
TargetDevice
Describes known device types.
Definition: ie_device.hpp:24
Defines a message that contains a list of appropriate plugin names.
Definition: ie_device.hpp:141
Definition: ie_argmax_layer.hpp:11
StatusCode
This enum contains codes for all possible return values of the interface functions.
Definition: ie_common.h:205
Defines a message that contains the InferenceEngine::TargetDevice object to find a plugin for...
Definition: ie_device.hpp:129
TargetDevice device
object of InferenceEngine::TargetDevice to find a plugin for
Definition: ie_device.hpp:133
Represents detailed information for an error.
Definition: ie_common.h:228
FindPluginResponse findPlugin(const FindPluginRequest &req)
Finds an appropriate plugin for requested target device.
The macro defines a symbol import/export mechanism essential for Microsoft Windows(R) OS...
const char * getDeviceName(TargetDevice device)
Returns the device name.
Definition: ie_device.hpp:118
Describes the relationship between the enumerator type and the actual device&#39;s name.
Definition: ie_device.hpp:41
static TargetDevice fromStr(const std::string &deviceName)
Converts string representation of device to InferenceEngine::TargetDevice enum value.
Definition: ie_device.hpp:75
static const char * name(TargetDevice device)
Converts an instance of InferenceEngine::TargetDevice to string representation.
Definition: ie_device.hpp:98
std::vector< std::string > names
A list of appropriate plugin names.
Definition: ie_device.hpp:145
This is a header file with common inference engine definitions.