1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * @brief This is a header file with common inference engine definitions.
14 #include <details/ie_exception.hpp>
20 #include "ie_unicode.hpp"
22 namespace InferenceEngine {
24 * @brief Represents tensor size.
26 * The order is opposite to the order in Caffe*: (w,h,n,b) where the most frequently changing element in memory is
29 using SizeVector = std::vector<size_t>;
32 * @brief This class represents the generic layer.
37 * @brief A smart pointer to the CNNLayer
39 using CNNLayerPtr = std::shared_ptr<CNNLayer>;
41 * @brief A smart weak pointer to the CNNLayer
43 using CNNLayerWeakPtr = std::weak_ptr<CNNLayer>;
46 * @brief The main data representation node
51 * @brief Smart pointer to Data
53 using DataPtr = std::shared_ptr<Data>;
56 * @brief Smart pointer to constant Data
58 using CDataPtr = std::shared_ptr<const Data>;
61 * @brief Smart weak pointer to Data
63 using DataWeakPtr = std::weak_ptr<Data>;
67 * @brief The method holds the user values to enable binding of data per graph node.
77 * @brief Layouts that the inference engine supports
79 enum Layout : uint8_t {
80 ANY = 0, // "any" layout
100 // Single image layout (for mean image)
110 inline std::ostream& operator<<(std::ostream& out, const Layout& p) {
112 #define PRINT_LAYOUT(name) \
128 PRINT_LAYOUT(BLOCKED);
131 out << static_cast<int>(p);
139 * @brief Extra information about input color format for preprocessing
141 enum ColorFormat : uint32_t {
142 RAW = 0u, ///< Plain blob (default), no extra color processing required
143 RGB, ///< RGB color format
144 BGR, ///< BGR color format, default in DLDT
145 RGBX, ///< RGBX color format with X ignored during inference
146 BGRX, ///< BGRX color format with X ignored during inference
147 NV12, ///< NV12 color format represented as compound Y+UV blob
148 I420, ///< I420 color format represented as compound Y+U+V blob
150 inline std::ostream& operator<<(std::ostream& out, const ColorFormat& fmt) {
152 #define PRINT_COLOR_FORMAT(name) \
157 PRINT_COLOR_FORMAT(RAW);
158 PRINT_COLOR_FORMAT(RGB);
159 PRINT_COLOR_FORMAT(BGR);
160 PRINT_COLOR_FORMAT(RGBX);
161 PRINT_COLOR_FORMAT(BGRX);
162 PRINT_COLOR_FORMAT(NV12);
163 PRINT_COLOR_FORMAT(I420);
164 #undef PRINT_COLOR_FORMAT
167 out << static_cast<uint32_t>(fmt);
174 * @struct InferenceEngineProfileInfo
175 * @brief Represents basic inference profiling information per layer.
177 * If the layer is executed using tiling, the sum time per each tile is indicated as the total execution time.
178 * Due to parallel execution, the total execution time for all layers might be greater than the total inference time.
180 struct InferenceEngineProfileInfo {
182 * @brief Defines the general status of the layer
184 enum LayerStatus { NOT_RUN, OPTIMIZED_OUT, EXECUTED };
188 * @brief The absolute time in microseconds that the layer ran (in total)
190 long long realTime_uSec;
192 * @brief The net host cpu time that the layer ran
197 * @brief An execution type of unit
199 char exec_type[256] = {};
202 * @brief A layer type
204 char layer_type[256] = {};
207 * @brief An execution index of the unit
209 unsigned execution_index;
214 * @brief This enum contains codes for all possible return values of the interface functions
216 enum StatusCode : int {
219 NOT_IMPLEMENTED = -2,
220 NETWORK_NOT_LOADED = -3,
221 PARAMETER_MISMATCH = -4,
225 * @brief exception not of std::exception derived type was thrown
229 RESULT_NOT_READY = -9,
231 INFER_NOT_STARTED = -11,
232 NETWORK_NOT_READ = -12
236 * @struct ResponseDesc
237 * @brief Represents detailed information for an error
239 struct ResponseDesc {
241 * @brief A character buffer that holds the detailed information for an error.
246 /** @brief This class represents StatusCode::GENERIC_ERROR exception */
247 class GeneralError : public std::logic_error {
248 using std::logic_error::logic_error;
251 /** @brief This class represents StatusCode::NOT_IMPLEMENTED exception */
252 class NotImplemented : public std::logic_error {
253 using std::logic_error::logic_error;
256 /** @brief This class represents StatusCode::NETWORK_NOT_LOADED exception */
257 class NetworkNotLoaded : public std::logic_error {
258 using std::logic_error::logic_error;
261 /** @brief This class represents StatusCode::PARAMETER_MISMATCH exception */
262 class ParameterMismatch : public std::logic_error {
263 using std::logic_error::logic_error;
266 /** @brief This class represents StatusCode::NOT_FOUND exception */
267 class NotFound : public std::logic_error {
268 using std::logic_error::logic_error;
271 /** @brief This class represents StatusCode::OUT_OF_BOUNDS exception */
272 class OutOfBounds : public std::logic_error {
273 using std::logic_error::logic_error;
276 /** @brief This class represents StatusCode::UNEXPECTED exception */
277 class Unexpected : public std::logic_error {
278 using std::logic_error::logic_error;
281 /** @brief This class represents StatusCode::REQUEST_BUSY exception */
282 class RequestBusy : public std::logic_error {
283 using std::logic_error::logic_error;
286 /** @brief This class represents StatusCode::RESULT_NOT_READY exception */
287 class ResultNotReady : public std::logic_error {
288 using std::logic_error::logic_error;
291 /** @brief This class represents StatusCode::NOT_ALLOCATED exception */
292 class NotAllocated : public std::logic_error {
293 using std::logic_error::logic_error;
296 /** @brief This class represents StatusCode::INFER_NOT_STARTED exception */
297 class InferNotStarted : public std::logic_error {
298 using std::logic_error::logic_error;
300 } // namespace InferenceEngine
302 /** @brief This class represents StatusCode::NETWORK_NOT_READ exception */
303 class NetworkNotRead : public std::logic_error {
304 using std::logic_error::logic_error;
308 #define __PRETTY_FUNCTION__ __FUNCSIG__
310 #define __PRETTY_FUNCTION__ __PRETTY_FUNCTION__