1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * @brief This is a header file with common inference engine definitions.
17 #include <details/ie_exception.hpp>
19 #include "ie_unicode.hpp"
21 namespace InferenceEngine {
23 * @brief Represents tensor size.
24 * The order is opposite to the order in Caffe*: (w,h,n,b) where the most frequently changing element in memory is first.
26 using SizeVector = std::vector<size_t>;
29 * @brief This class represents the generic layer.
34 * @brief A smart pointer to the CNNLayer
36 using CNNLayerPtr = std::shared_ptr<CNNLayer>;
38 * @brief A smart weak pointer to the CNNLayer
40 using CNNLayerWeakPtr = std::weak_ptr<CNNLayer>;
43 * @brief The main data representation node
48 * @brief Smart pointer to Data
50 using DataPtr = std::shared_ptr<Data>;
53 * @brief Smart pointer to constant Data
55 using CDataPtr = std::shared_ptr<const Data>;
58 * @brief Smart weak pointer to Data
60 using DataWeakPtr = std::weak_ptr<Data>;
64 * @brief The method holds the user values to enable binding of data per graph node.
74 * @brief Layouts that the inference engine supports
76 enum Layout : uint8_t {
77 ANY = 0, // "any" layout
94 // Single image layout (for mean image)
104 inline std::ostream & operator << (std::ostream &out, const Layout & p) {
106 #define PRINT_LAYOUT(name)\
107 case name : out << #name; break;
120 PRINT_LAYOUT(BLOCKED);
123 out << static_cast<int>(p);
131 * @brief Extra information about input color format for preprocessing
133 enum ColorFormat : uint32_t {
134 RAW = 0u, ///< Plain blob (default), no extra color processing required
135 RGB, ///< RGB color format
136 BGR, ///< BGR color format, default in DLDT
137 RGBX, ///< RGBX color format with X ignored during inference
138 BGRX, ///< BGRX color format with X ignored during inference
139 NV12, ///< NV12 color format represented as compound Y+UV blob
141 inline std::ostream & operator << (std::ostream &out, const ColorFormat & fmt) {
143 #define PRINT_COLOR_FORMAT(name) \
144 case name : out << #name; break;
146 PRINT_COLOR_FORMAT(RAW);
147 PRINT_COLOR_FORMAT(RGB);
148 PRINT_COLOR_FORMAT(BGR);
149 PRINT_COLOR_FORMAT(RGBX);
150 PRINT_COLOR_FORMAT(BGRX);
151 PRINT_COLOR_FORMAT(NV12);
153 #undef PRINT_COLOR_FORMAT
155 default: out << static_cast<uint32_t>(fmt); break;
161 * @struct InferenceEngineProfileInfo
162 * @brief Represents basic inference profiling information per layer.
163 * If the layer is executed using tiling, the sum time per each tile is indicated as the total execution time.
164 * Due to parallel execution, the total execution time for all layers might be greater than the total inference time.
166 struct InferenceEngineProfileInfo {
168 * @brief Defines the general status of the layer
178 * @brief The absolute time in microseconds that the layer ran (in total)
180 long long realTime_uSec;
182 * @brief The net host cpu time that the layer ran
187 * @brief An execution type of unit
189 char exec_type[256] = {};
192 * @brief A layer type
194 char layer_type[256] = {};
197 * @brief An execution index of the unit
199 unsigned execution_index;
205 * @brief This enum contains codes for all possible return values of the interface functions
207 enum StatusCode : int {
210 NOT_IMPLEMENTED = -2,
211 NETWORK_NOT_LOADED = -3,
212 PARAMETER_MISMATCH = -4,
216 * @brief exception not of std::exception derived type was thrown
220 RESULT_NOT_READY = -9,
222 INFER_NOT_STARTED = -11,
223 NETWORK_NOT_READ = -12
227 * @struct ResponseDesc
228 * @brief Represents detailed information for an error
230 struct ResponseDesc {
232 * @brief A character buffer that holds the detailed information for an error.
237 /** @brief This class represents StatusCode::GENERIC_ERROR exception */
238 class GeneralError : public std::logic_error
239 { using std::logic_error::logic_error; };
241 /** @brief This class represents StatusCode::NOT_IMPLEMENTED exception */
242 class NotImplemented : public std::logic_error
243 { using std::logic_error::logic_error; };
245 /** @brief This class represents StatusCode::NETWORK_NOT_LOADED exception */
246 class NetworkNotLoaded : public std::logic_error
247 { using std::logic_error::logic_error; };
249 /** @brief This class represents StatusCode::PARAMETER_MISMATCH exception */
250 class ParameterMismatch : public std::logic_error
251 { using std::logic_error::logic_error; };
253 /** @brief This class represents StatusCode::NOT_FOUND exception */
254 class NotFound : public std::logic_error
255 { using std::logic_error::logic_error; };
257 /** @brief This class represents StatusCode::OUT_OF_BOUNDS exception */
258 class OutOfBounds : public std::logic_error
259 { using std::logic_error::logic_error; };
261 /** @brief This class represents StatusCode::UNEXPECTED exception */
262 class Unexpected : public std::logic_error
263 { using std::logic_error::logic_error; };
265 /** @brief This class represents StatusCode::REQUEST_BUSY exception */
266 class RequestBusy : public std::logic_error
267 { using std::logic_error::logic_error; };
269 /** @brief This class represents StatusCode::RESULT_NOT_READY exception */
270 class ResultNotReady : public std::logic_error
271 { using std::logic_error::logic_error; };
273 /** @brief This class represents StatusCode::NOT_ALLOCATED exception */
274 class NotAllocated : public std::logic_error
275 { using std::logic_error::logic_error; };
277 /** @brief This class represents StatusCode::INFER_NOT_STARTED exception */
278 class InferNotStarted : public std::logic_error
279 { using std::logic_error::logic_error; };
280 } // namespace InferenceEngine
282 /** @brief This class represents StatusCode::NETWORK_NOT_READ exception */
283 class NetworkNotRead : public std::logic_error
284 { using std::logic_error::logic_error; };
287 #define __PRETTY_FUNCTION__ __FUNCSIG__
289 #define __PRETTY_FUNCTION__ __PRETTY_FUNCTION__