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  */
72  INFERENCE_ENGINE_DEPRECATED
73  static TargetDevice fromStr(const std::string &deviceName) {
74  static std::map<std::string, InferenceEngine::TargetDevice> deviceFromNameMap = {
75  { "CPU", InferenceEngine::TargetDevice::eCPU },
76  { "GPU", InferenceEngine::TargetDevice::eGPU },
77  { "FPGA", InferenceEngine::TargetDevice::eFPGA },
78  { "MYRIAD", InferenceEngine::TargetDevice::eMYRIAD },
79  { "HDDL", InferenceEngine::TargetDevice::eHDDL },
80  { "GNA", InferenceEngine::TargetDevice::eGNA },
81  { "BALANCED", InferenceEngine::TargetDevice::eBalanced },
82  { "HETERO", InferenceEngine::TargetDevice::eHETERO },
83  { "MULTI", InferenceEngine::TargetDevice::eMULTI}
84  };
85  auto val = deviceFromNameMap.find(deviceName);
86  return val != deviceFromNameMap.end() ? val->second : InferenceEngine::TargetDevice::eDefault;
87  }
88 
89  /**
90  * @deprecated Deprecated since InferenceEngine::TargetDevice is deprecated
91  * @brief Converts InferenceEngine::TargetDevice enum value to string representation
92  */
93  INFERENCE_ENGINE_DEPRECATED
94  static const char * name(TargetDevice device) {
95  IE_SUPPRESS_DEPRECATED_START
96  auto res = std::find_if(getAll().cbegin(), getAll().cend(), [&](const Info & info){
97  return device == info.device;
98  });
99  if (res == getAll().cend()) {
100  return "Unknown device";
101  }
102  IE_SUPPRESS_DEPRECATED_END
103  return res->name.c_str();
104  }
105 };
106 
107 /**
108  * @deprecated Deprecated since InferenceEngine::TargetDevice is deprecated
109  * @brief Returns the device name
110  * @param device Instance of InferenceEngine::TargetDevice
111  * @return A c-string with the name
112  */
113 INFERENCE_ENGINE_DEPRECATED
114 inline const char *getDeviceName(TargetDevice device) {
115  IE_SUPPRESS_DEPRECATED_START
116  return TargetDeviceInfo::name(device);
117  IE_SUPPRESS_DEPRECATED_END
118 }
119 
120 /**
121  * @deprecated Deprecated since InferenceEngine::TargetDevice is deprecated
122  * @struct FindPluginRequest
123  * @brief Defines a message that contains the InferenceEngine::TargetDevice object to find a plugin for
124  */
125 struct INFERENCE_ENGINE_DEPRECATED FindPluginRequest {
126  /**
127  * @brief object of InferenceEngine::TargetDevice to find a plugin for
128  */
130 };
131 
132 /**
133  * @deprecated Deprecated since InferenceEngine::TargetDevice is deprecated
134  * @struct FindPluginResponse
135  * @brief Defines a message that contains a list of appropriate plugin names
136  */
137 struct INFERENCE_ENGINE_DEPRECATED FindPluginResponse {
138  /**
139  * @brief A list of appropriate plugin names
140  */
141  std::vector<std::string> names;
142 };
143 
144 IE_SUPPRESS_DEPRECATED_START
145 
146 /**
147  * @deprecated Deprecated since InferenceEngine::TargetDevice is deprecated
148  * @brief Finds an appropriate plugin for requested target device
149  * @param req A requested target device
150  * @return A response object
151  */
153 
154 /**
155  * @deprecated Deprecated since InferenceEngine::TargetDevice is deprecated
156  * @brief Finds an appropriate plugin for requested target device
157  * @param req A requested target device
158  * @param result The results of the request
159  * @param resp The response message description
160  * @return A status code
161  */
162 INFERENCE_ENGINE_API(StatusCode) findPlugin(const FindPluginRequest &req, FindPluginResponse &result,
163  ResponseDesc *resp) noexcept;
164 
165 IE_SUPPRESS_DEPRECATED_END
166 
167 } // 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:137
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:125
TargetDevice device
object of InferenceEngine::TargetDevice to find a plugin for
Definition: ie_device.hpp:129
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:114
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:73
static const char * name(TargetDevice device)
Converts InferenceEngine::TargetDevice enum value to string representation.
Definition: ie_device.hpp:94
std::vector< std::string > names
A list of appropriate plugin names.
Definition: ie_device.hpp:141
This is a header file with common inference engine definitions.