ie_c_api.h
Go to the documentation of this file.
1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 /**
6  * @file ie_c_api.h
7  * C API of Inference Engine bridge unlocks using of OpenVINO Inference Engine
8  * library and all its plugins in native applications disabling usage
9  * of C++ API. The scope of API covers significant part of C++ API and includes
10  * an ability to read model from the disk, modify input and output information
11  * to correspond their runtime representation like data types or memory layout,
12  * load in-memory model to Inference Engine on different devices including
13  * heterogeneous and multi-device modes, manage memory where input and output
14  * is allocated and manage inference flow.
15 **/
16 
17 #ifndef IE_C_API_H
18 #define IE_C_API_H
19 
20 #include <stdint.h>
21 #include <stdio.h>
22 
23 #ifdef __cplusplus
24  #define INFERENCE_ENGINE_C_API_EXTERN extern "C"
25 #else
26  #define INFERENCE_ENGINE_C_API_EXTERN
27 #endif
28 
29 #if defined(__GNUC__) && (__GNUC__ < 4)
30  #define INFERENCE_ENGINE_C_API(...) INFERENCE_ENGINE_C_API_EXTERN __VA_ARGS__
31  #define IE_NODISCARD
32 #else
33  #if defined(_WIN32)
34  #define INFERENCE_ENGINE_C_API_CALLBACK __cdecl
35  #ifdef inference_engine_c_api_EXPORTS
36  #define INFERENCE_ENGINE_C_API(...) INFERENCE_ENGINE_C_API_EXTERN __declspec(dllexport) __VA_ARGS__ __cdecl
37  #else
38  #define INFERENCE_ENGINE_C_API(...) INFERENCE_ENGINE_C_API_EXTERN __declspec(dllimport) __VA_ARGS__ __cdecl
39  #endif
40  #define IE_NODISCARD
41  #else
42  #define INFERENCE_ENGINE_C_API(...) INFERENCE_ENGINE_C_API_EXTERN __attribute__((visibility("default"))) __VA_ARGS__
43  #define IE_NODISCARD __attribute__((warn_unused_result))
44  #endif
45 #endif
46 
47 #ifndef INFERENCE_ENGINE_C_API_CALLBACK
48 #define INFERENCE_ENGINE_C_API_CALLBACK
49 #endif
50 
51 typedef struct ie_core ie_core_t;
52 typedef struct ie_network ie_network_t;
53 typedef struct ie_executable ie_executable_network_t;
54 typedef struct ie_infer_request ie_infer_request_t;
55 typedef struct ie_blob ie_blob_t;
56 
57 /**
58  * @struct ie_version
59  * @brief Represents an API version information that reflects the set of supported features
60  */
61 typedef struct ie_version {
62  char *api_version;
64 
65 /**
66  * @struct ie_core_version
67  * @brief Represents version information that describes devices and the inference engine runtime library
68  */
69 typedef struct ie_core_version {
70  size_t major;
71  size_t minor;
72  const char *device_name;
73  const char *build_number;
74  const char *description;
76 
77 /**
78  * @struct ie_core_versions
79  * @brief Represents all versions information that describes all devices and the inference engine runtime library
80  */
81 typedef struct ie_core_versions {
82  ie_core_version_t *versions;
83  size_t num_vers;
85 
86 /**
87  * @struct ie_config
88  * @brief Represents configuration information that describes devices
89  */
90 typedef struct ie_config {
91  const char *name;
92  const char *value;
93  struct ie_config *next;
95 
96 /**
97  * @struct ie_param
98  * @brief metric and config parameters.
99  */
100 typedef struct ie_param {
101  union {
102  char *params;
103  unsigned int number;
104  unsigned int range_for_async_infer_request[3];
105  unsigned int range_for_streams[2];
106  };
107 }ie_param_t;
108 
109 /**
110  * @struct ie_param_config
111  * @brief Represents configuration parameter information
112  */
113 typedef struct ie_param_config {
114  char *name;
115  ie_param_t *param;
117 
118 /**
119  * @struct desc
120  * @brief Represents detailed information for an error
121  */
122 typedef struct desc {
123  char msg[256];
124 }desc_t;
125 
126 /**
127  * @struct dimensions
128  * @brief Represents dimensions for input or output data
129  */
130 typedef struct dimensions {
131  size_t ranks;
132  size_t dims[8];
133 }dimensions_t;
134 
135 /**
136  * @enum layout_e
137  * @brief Layouts that the inference engine supports
138  */
139 typedef enum {
140  ANY = 0, // "any" layout
141 
142  // I/O data layouts
143  NCHW = 1,
144  NHWC = 2,
145  NCDHW = 3,
146  NDHWC = 4,
147 
148  // weight layouts
149  OIHW = 64,
150 
151  // Scalar
152  SCALAR = 95,
153 
154  // bias layouts
155  C = 96,
156 
157  // Single image layout (for mean image)
158  CHW = 128,
159 
160  // 2D
161  HW = 192,
162  NC = 193,
163  CN = 194,
164 
165  BLOCKED = 200,
166 }layout_e;
167 
168 /**
169  * @enum precision_e
170  * @brief Precisions that the inference engine supports
171  */
172 typedef enum {
173  UNSPECIFIED = 255, /**< Unspecified value. Used by default */
174  MIXED = 0, /**< Mixed value. Can be received from network. No applicable for tensors */
175  FP32 = 10, /**< 32bit floating point value */
176  FP16 = 11, /**< 16bit floating point value */
177  Q78 = 20, /**< 16bit specific signed fixed point precision */
178  I16 = 30, /**< 16bit signed integer value */
179  U8 = 40, /**< 8bit unsigned integer value */
180  I8 = 50, /**< 8bit signed integer value */
181  U16 = 60, /**< 16bit unsigned integer value */
182  I32 = 70, /**< 32bit signed integer value */
183  I64 = 72, /**< 64bit signed integer value */
184  U64 = 73, /**< 64bit unsigned integer value */
185  U32 = 74, /**< 32bit unsigned integer value */
186  BIN = 71, /**< 1bit integer value */
187  CUSTOM = 80 /**< custom precision has it's own name and size of elements */
189 
190 /**
191  * @struct tensor_desc
192  * @brief Represents detailed information for a tensor
193  */
194 typedef struct tensor_desc {
195  layout_e layout;
196  dimensions_t dims;
197  precision_e precision;
199 
200 /**
201  * @enum colorformat_e
202  * @brief Extra information about input color format for preprocessing
203  */
204 typedef enum {
205  RAW = 0u, ///< Plain blob (default), no extra color processing required
206  RGB, ///< RGB color format
207  BGR, ///< BGR color format, default in DLDT
208  RGBX, ///< RGBX color format with X ignored during inference
209  BGRX, ///< BGRX color format with X ignored during inference
210  NV12, ///< NV12 color format represented as compound Y+UV blob
211  I420, ///< I420 color format represented as compound Y+U+V blob
213 
214 /**
215  * @enum resize_alg_e
216  * @brief Represents the list of supported resize algorithms.
217  */
218 typedef enum {
219  NO_RESIZE = 0,
220  RESIZE_BILINEAR,
221  RESIZE_AREA
222 }resize_alg_e;
223 
224 /**
225  * @enum IEStatusCode
226  * @brief This enum contains codes for all possible return values of the interface functions
227  */
228 typedef enum {
229  OK = 0,
230  GENERAL_ERROR = -1,
231  NOT_IMPLEMENTED = -2,
232  NETWORK_NOT_LOADED = -3,
233  PARAMETER_MISMATCH = -4,
234  NOT_FOUND = -5,
235  OUT_OF_BOUNDS = -6,
236  /*
237  * @brief exception not of std::exception derived type was thrown
238  */
239  UNEXPECTED = -7,
240  REQUEST_BUSY = -8,
241  RESULT_NOT_READY = -9,
242  NOT_ALLOCATED = -10,
243  INFER_NOT_STARTED = -11,
244  NETWORK_NOT_READ = -12
245 }IEStatusCode;
246 
247 /**
248  * @struct roi_t
249  * @brief This structure describes roi data.
250  */
251 typedef struct roi {
252  size_t id; // ID of a roi
253  size_t posX; // W upper left coordinate of roi
254  size_t posY; // H upper left coordinate of roi
255  size_t sizeX; // W size of roi
256  size_t sizeY; // H size of roi
257 }roi_t;
258 
259 /**
260  * @struct input_shape
261  * @brief Represents shape for input data
262  */
263 typedef struct input_shape {
264  char *name;
265  dimensions_t shape;
267 
268 /**
269  * @struct input_shapes
270  * @brief Represents shapes for all input data
271  */
272 typedef struct input_shapes {
273  input_shape_t *shapes;
274  size_t shape_num;
276 
277 /**
278  * @struct ie_blob_buffer
279  * @brief Represents copied data from the given blob.
280  */
281 typedef struct ie_blob_buffer {
282  union {
283  void *buffer; // buffer can be written
284  const void *cbuffer; // cbuffer is read-only
285  };
287 
288 /**
289  * @struct ie_complete_call_back
290  * @brief Completion callback definition about the function and args
291  */
292 typedef struct ie_complete_call_back {
293  void (INFERENCE_ENGINE_C_API_CALLBACK *completeCallBackFunc)(void *args);
294  void *args;
296 
297 /**
298  * @struct ie_available_devices
299  * @brief Represent all available devices.
300  */
301 typedef struct ie_available_devices {
302  char **devices;
303  size_t num_devices;
305 
306 /**
307  * @brief Returns number of version that is exported. Use the ie_version_free() to free memory.
308  * @return Version number of the API.
309  */
310 INFERENCE_ENGINE_C_API(ie_version_t) ie_c_api_version(void);
311 
312 /**
313  * @brief Release the memory allocated by ie_c_api_version.
314  * @param version A pointer to the ie_version_t to free memory.
315  */
316 INFERENCE_ENGINE_C_API(void) ie_version_free(ie_version_t *version);
317 
318 /**
319  * @brief Release the memory allocated by ie_param_t.
320  * @param version A pointer to the ie_param_t to free memory.
321  */
322 INFERENCE_ENGINE_C_API(void) ie_param_free(ie_param_t *param);
323 
324 // Core
325 
326 /**
327  * @defgroup Core Core
328  * Set of functions dedicated to working with registered plugins and loading
329  * network to the registered devices.
330  * @{
331  */
332 
333 /**
334  * @brief Constructs Inference Engine Core instance using XML configuration file with devices description.
335  * See RegisterPlugins for more details. Use the ie_core_free() method to free memory.
336  * @ingroup Core
337  * @param xml_config_file A path to .xml file with devices to load from. If XML configuration file is not specified,
338  * then default Inference Engine devices are loaded from the default plugin.xml file.
339  * @param core A pointer to the newly created ie_core_t.
340  * @return Status code of the operation: OK(0) for success.
341  */
342 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_core_create(const char *xml_config_file, ie_core_t **core);
343 
344 /**
345  * @brief Releases memory occupied by core.
346  * @ingroup Core
347  * @param core A pointer to the core to free memory.
348  */
349 INFERENCE_ENGINE_C_API(void) ie_core_free(ie_core_t **core);
350 
351 /**
352  * @brief Gets version information of the device specified. Use the ie_core_versions_free() method to free memory.
353  * @ingroup Core
354  * @param core A pointer to ie_core_t instance.
355  * @param device_name Name to indentify device.
356  * @param versions A pointer to versions corresponding to device_name.
357  * @return Status code of the operation: OK(0) for success.
358  */
359 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_core_get_versions(const ie_core_t *core, const char *device_name, ie_core_versions_t *versions);
360 
361 /**
362  * @brief Releases memory occupied by ie_core_versions.
363  * @ingroup Core
364  * @param vers A pointer to the ie_core_versions to free memory.
365  */
366 INFERENCE_ENGINE_C_API(void) ie_core_versions_free(ie_core_versions_t *vers);
367 
368 /**
369  * @brief Reads the model from the .xml and .bin files of the IR. Use the ie_network_free() method to free memory.
370  * @ingroup Core
371  * @param core A pointer to ie_core_t instance.
372  * @param xml .xml file's path of the IR.
373  * @param weights_file .bin file's path of the IR, if path is empty, will try to read bin file with the same name as xml and
374  * if bin file with the same name was not found, will load IR without weights.
375  * @param network A pointer to the newly created network.
376  * @return Status code of the operation: OK(0) for success.
377  */
378 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_core_read_network(ie_core_t *core, const char *xml, const char *weights_file, ie_network_t **network);
379 
380 /**
381  * @brief Reads the model from an xml string and a blob of the bin part of the IR. Use the ie_network_free() method to free memory.
382  * @ingroup Core
383  * @param core A pointer to ie_core_t instance.
384  * @param xml_content Xml content of the IR.
385  * @param xml_content_size Number of bytes in the xml content of the IR.
386  * @param weight_blob Blob containing the bin part of the IR.
387  * @param network A pointer to the newly created network.
388  * @return Status code of the operation: OK(0) for success.
389  */
390 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_core_read_network_from_memory(ie_core_t *core, const uint8_t *xml_content, size_t xml_content_size,
391  const ie_blob_t *weight_blob, ie_network_t **network);
392 
393 /**
394  * @brief Creates an executable network from a network object. Users can create as many networks as they need and use
395  * them simultaneously (up to the limitation of the hardware resources). Use the ie_exec_network_free() method to free memory.
396  * @ingroup Core
397  * @param core A pointer to ie_core_t instance.
398  * @param network A pointer to ie_network instance.
399  * @param device_name Name of device to load network to.
400  * @param config Device configuration.
401  * @param exe_network A pointer to the newly created executable network.
402  * @return Status code of the operation: OK(0) for success.
403  */
404 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_core_load_network(ie_core_t *core, const ie_network_t *network, const char *device_name, \
405  const ie_config_t *config, ie_executable_network_t **exe_network);
406 
407 /**
408  * @brief Sets configuration for device.
409  * @ingroup Core
410  * @param core A pointer to ie_core_t instance.
411  * @param ie_core_config Device configuration.
412  * @param device_name An optinal name of a device. If device name is not specified,
413  * the config is set for all the registered devices.
414  * @return Status code of the operation: OK(0) for success.
415  */
416 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_core_set_config(ie_core_t *core, const ie_config_t *ie_core_config, const char *device_name);
417 
418 /**
419  * @brief Registers a new device and a plugin which implement this device inside Inference Engine.
420  * @ingroup Core
421  * @param core A pointer to ie_core_t instance.
422  * @param plugin_name A name of a plugin. Depending on a platform, plugin_name is wrapped with
423  * a shared library suffix and a prefix to identify a full name of the library.
424  * @param device_name A device name to register plugin for. If not specified, the method registers
425  * a plugin with the default name.
426  * @return Status code of the operation: OK(0) for success.
427  */
428 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_core_register_plugin(ie_core_t *core, const char *plugin_name, const char *device_name);
429 
430 /**
431  * @brief Registers plugins specified in an ".xml" configuration file.
432  * @ingroup Core
433  * @param core A pointer to ie_core_t instance.
434  * @param xml_config_file A full path to ".xml" file containing plugins configuration.
435  * @return Status code of the operation: OK(0) for success.
436  */
437 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_core_register_plugins(ie_core_t *core, const char *xml_config_file);
438 
439 /**
440  * @brief Unregisters a plugin with a specified device name.
441  * @ingroup Core
442  * @param core A pointer to ie_core_t instance.
443  * @param device_name A device name of the device to unregister.
444  * @return Status code of the operation: OK(0) for success.
445  */
446 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_core_unregister_plugin(ie_core_t *core, const char *device_name);
447 
448 /**
449  * @brief Loads extension library to the device with a specified device name.
450  * @ingroup Core
451  * @param core A pointer to ie_core_t instance.
452  * @param extension_path Path to the extensions library file to load to a device.
453  * @param device_name A device name of a device to load the extensions to.
454  * @return Status code of the operation: OK(0) for success.
455  */
456 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_core_add_extension(ie_core_t *core, const char *extension_path, const char *device_name);
457 
458 /**
459  * @brief Gets general runtime metric for dedicated hardware. The method is needed to request common device properties
460  * which are executable network agnostic. It can be device name, temperature, other devices-specific values.
461  * @ingroup Core
462  * @param core A pointer to ie_core_t instance.
463  * @param device_name A name of a device to get a metric value.
464  * @param metric_name A metric name to request.
465  * @param param_result A metric value corresponding to the metric_name.
466  * @return Status code of the operation: OK(0) for success.
467  */
468 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_core_get_metric(const ie_core_t *core, const char *device_name, const char *metric_name, ie_param_t *param_result);
469 
470 /**
471  * @brief Gets configuration dedicated to device behaviour. The method is targeted to extract information
472  * which can be set via SetConfig method.
473  * @ingroup Core
474  * @param core A pointer to ie_core_t instance.
475  * @param device_name A name of a device to get a configuration value.
476  * @param config_name Name of a configuration.
477  * @param param_result A configuration value corresponding to the config_name.
478  * @return Status code of the operation: OK(0) for success.
479  */
480 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_core_get_config(const ie_core_t *core, const char *device_name, const char *config_name, ie_param_t *param_result);
481 
482 /**
483  * @brief Gets available devices for neural network inference.
484  * @ingroup Core
485  * @param core A pointer to ie_core_t instance.
486  * @param avai_devices The devices are returned as { CPU, FPGA.0, FPGA.1, MYRIAD }
487  * If there more than one device of specific type, they are enumerated with .# suffix
488  * @return Status code of the operation: OK(0) for success.
489  */
490 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_core_get_available_devices(const ie_core_t *core, ie_available_devices_t *avai_devices);
491 
492 /**
493  * @brief Releases memory occpuied by ie_available_devices_t
494  * @ingroup Core
495  * @param avai_devices A pointer to the ie_available_devices_t to free memory.
496  */
497 INFERENCE_ENGINE_C_API(void) ie_core_available_devices_free(ie_available_devices_t *avai_devices);
498 
499 /** @} */ // end of Core
500 
501 // ExecutableNetwork
502 
503 /**
504  * @defgroup ExecutableNetwork ExecutableNetwork
505  * Set of functions representing of neural networks been loaded to device.
506  * @{
507  */
508 
509 /**
510  * @brief Releases memory occupied by ExecutableNetwork.
511  * @ingroup ExecutableNetwork
512  * @param ie_exec_network A pointer to the ExecutableNetwork to free memory.
513  */
514 INFERENCE_ENGINE_C_API(void) ie_exec_network_free(ie_executable_network_t **ie_exec_network);
515 
516 /**
517  * @brief Creates an inference request instance used to infer the network. The created request has allocated input
518  * and output blobs (that can be changed later). Use the ie_infer_request_free() method to free memory.
519  * @ingroup ExecutableNetwork
520  * @param ie_exec_network A pointer to ie_executable_network_t instance.
521  * @param request A pointer to the newly created ie_infer_request_t instance
522  * @return Status code of the operation: OK(0) for success.
523  */
524 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_exec_network_create_infer_request(ie_executable_network_t *ie_exec_network, ie_infer_request_t **request);
525 
526 /**
527  * @brief Gets general runtime metric for an executable network. It can be network name, actual device ID on which executable network is running
528  * or all other properties which cannot be changed dynamically.
529  * @ingroup ExecutableNetwork
530  * @param ie_exec_network A pointer to ie_executable_network_t instance.
531  * @param metric_name A metric name to request.
532  * @param param_result A metric value corresponding to the metric_name.
533  * @return Status code of the operation: OK(0) for success.
534  */
535 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_exec_network_get_metric(const ie_executable_network_t *ie_exec_network, \
536  const char *metric_name, ie_param_t *param_result);
537 
538 /**
539  * @brief Sets configuration for current executable network. Currently, the method can be used
540  * when the network run on the Multi device and the configuration paramter is only can be "MULTI_DEVICE_PRIORITIES"
541  * @ingroup ExecutableNetwork
542  * @param ie_exec_network A pointer to ie_executable_network_t instance.
543  * @param param_config A pointer to device configuration..
544  * @return Status code of the operation: OK(0) for success.
545  */
546 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_exec_network_set_config(ie_executable_network_t *ie_exec_network, const ie_config_t *param_config);
547 
548 /**
549  * @brief Gets configuration for current executable network. The method is responsible to
550  * extract information which affects executable network execution.
551  * @ingroup ExecutableNetwork
552  * @param ie_exec_network A pointer to ie_executable_network_t instance.
553  * @param metric_config A configuration parameter name to request.
554  * @param param_result A configuration value corresponding to a configuration paramter name.
555  * @return Status code of the operation: OK(0) for success.
556  */
557 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_exec_network_get_config(const ie_executable_network_t *ie_exec_network, \
558  const char *metric_config, ie_param_t *param_result);
559 
560 /** @} */ // end of ExecutableNetwork
561 
562 // InferRequest
563 
564 /**
565  * @defgroup InferRequest InferRequest
566  * Set of functions responsible for dedicated inference for certain
567  * ExecutableNetwork.
568  * @{
569  */
570 
571 /**
572  * @brief Releases memory occupied by ie_infer_request_t instance.
573  * @ingroup InferRequest
574  * @param infer_request A pointer to the ie_infer_request_t to free memory.
575  */
576 INFERENCE_ENGINE_C_API(void) ie_infer_request_free(ie_infer_request_t **infer_request);
577 
578 /**
579  * @brief Gets input/output data for inference
580  * @ingroup InferRequest
581  * @param infer_request A pointer to ie_infer_request_t instance.
582  * @param name Name of input or output blob.
583  * @param blob A pointer to input or output blob. The type of Blob must match the network input precision and size.
584  * @return Status code of the operation: OK(0) for success.
585  */
586 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_infer_request_get_blob(ie_infer_request_t *infer_request, const char *name, ie_blob_t **blob);
587 
588 /**
589  * @brief Sets input/output data to inference.
590  * @ingroup InferRequest
591  * @param infer_request A pointer to ie_infer_request_t instance.
592  * @param name Name of input or output blob.
593  * @param blob Reference to input or output blob. The type of a blob must match the network input precision and size.
594  * @return Status code of the operation: OK(0) for success.
595  */
596 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_infer_request_set_blob(ie_infer_request_t *infer_request, const char *name, const ie_blob_t *blob);
597 
598 /**
599  * @brief Starts synchronous inference of the infer request and fill outputs.
600  * @ingroup InferRequest
601  * @param infer_request A pointer to ie_infer_request_t instance.
602  * @return Status code of the operation: OK(0) for success.
603  */
604 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_infer_request_infer(ie_infer_request_t *infer_request);
605 
606 /**
607  * @brief Starts asynchronous inference of the infer request and fill outputs.
608  * @ingroup InferRequest
609  * @param infer_request A pointer to ie_infer_request_t instance.
610  * @return Status code of the operation: OK(0) for success.
611  */
612 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_infer_request_infer_async(ie_infer_request_t *infer_request);
613 
614 /**
615  * @brief Sets a callback function that will be called on success or failure of asynchronous request
616  * @ingroup InferRequest
617  * @param infer_request A pointer to ie_infer_request_t instance.
618  * @param callback A function to be called.
619  * @return Status code of the operation: OK(0) for success.
620  */
621 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_infer_set_completion_callback(ie_infer_request_t *infer_request, ie_complete_call_back_t *callback);
622 
623 /**
624  * @brief Waits for the result to become available. Blocks until specified timeout elapses or the result becomes available, whichever comes first.
625  * @ingroup InferRequest
626  * @param infer_request A pointer to ie_infer_request_t instance.
627  * @param timeout Maximum duration in milliseconds to block for
628  * @note There are special cases when timeout is equal some value of the WaitMode enum:
629  * * 0 - Immediately returns the inference status. It does not block or interrupt execution.
630  * * -1 - waits until inference result becomes available
631  * @return Status code of the operation: OK(0) for success.
632  */
633 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_infer_request_wait(ie_infer_request_t *infer_request, const int64_t timeout);
634 
635 /**
636  * @brief Sets new batch size for certain infer request when dynamic batching is enabled in executable network that created this request.
637  * @ingroup InferRequest
638  * @param infer_request A pointer to ie_infer_request_t instance.
639  * @param size New batch size to be used by all the following inference calls for this request.
640  * @return Status code of the operation: OK(0) for success.
641  */
642 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_infer_request_set_batch(ie_infer_request_t *infer_request, const size_t size);
643 
644 /** @} */ // end of InferRequest
645 
646 // Network
647 
648 /**
649  * @defgroup Network Network
650  * Set of functions managing network been read from the IR before loading
651  * of it to the device.
652  * @{
653  */
654 
655 /**
656  * @brief When netowrk is loaded into the Infernece Engine, it is not required anymore and should be released
657  * @ingroup Network
658  * @param network The pointer to the instance of the ie_network_t to free.
659  */
660 INFERENCE_ENGINE_C_API(void) ie_network_free(ie_network_t **network);
661 
662 /**
663  * @brief Get name of network.
664  * @ingroup Network
665  * @param name Name of the network.
666  * @return Status code of the operation: OK(0) for success.
667  */
668 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_get_name(const ie_network_t *network, char **name);
669 
670 /**
671  * @brief Gets number of inputs for the network.
672  * @ingroup Network
673  * @param network A pointer to the instance of the ie_network_t to get number of input information.
674  * @param size_result A number of the instance's input information.
675  * @return Status code of the operation: OK(0) for success.
676  */
677 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_get_inputs_number(const ie_network_t *network, size_t *size_result);
678 
679 /**
680  * @brief Gets name corresponding to the "number". Use the ie_network_name_free() method to free memory.
681  * @ingroup Network
682  * @param network A pointer to theinstance of the ie_network_t to get input information.
683  * @param number An id of input information .
684  * @param name Input name corresponding to the number.
685  * @return status Status code of the operation: OK(0) for success.
686  */
687 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_get_input_name(const ie_network_t *network, size_t number, char **name);
688 
689 /**
690  * @brief Gets a precision of the input data provided by user.
691  * @ingroup Network
692  * @param network A pointer to ie_network_t instance.
693  * @param input_name Name of input data.
694  * @param prec_result A pointer to the precision used for input blob creation.
695  * @return Status code of the operation: OK(0) for success.
696  */
697 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_get_input_precision(const ie_network_t *network, const char *input_name, precision_e *prec_result);
698 
699 /**
700  * @brief Changes the precision of the input data provided by the user.
701  * This function should be called before loading the network to the device.
702  * @ingroup Network
703  * @param network A pointer to ie_network_t instance.
704  * @param input_name Name of input data.
705  * @param p A new precision of the input data to set (eg. precision_e.FP16).
706  * @return Status code of the operation: OK(0) for success.
707  */
708 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_set_input_precision(ie_network_t *network, const char *input_name, const precision_e p);
709 
710 /**
711  * @brief Gets a layout of the input data.
712  * @ingroup Network
713  * @param network A pointer to ie_network_t instance.
714  * @param input_name Name of input data.
715  * @param layout_result A pointer to the layout used for input blob creation.
716  * @return Status code of the operation: OK(0) for success.
717  */
718 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_get_input_layout(const ie_network_t *network, const char *input_name, layout_e *layout_result);
719 
720 /**
721  * @brief Changes the layout of the input data named "input_name".
722  * This function should be called before loading the network to the device.
723  * @ingroup Network
724  * @param network A pointer to ie_network_t instance.
725  * @param input_name Name of input data.
726  * @param l A new layout of the input data to set.
727  * @return Status code of the operation: OK(0) for success.
728  */
729 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_set_input_layout(ie_network_t *network, const char *input_name, const layout_e l);
730 
731 /**
732  * @Gets dimensions/shape of the input data with reversed order.
733  * @ingroup Network
734  * @param network A pointer to ie_network_t instance.
735  * @param input_name Name of input data.
736  * @param dims_result A pointer to the dimensions used for input blob creation.
737  * @return Status code of the operation: OK(0) for success.
738  */
739 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_get_input_dims(const ie_network_t *network, const char *input_name, dimensions_t *dims_result);
740 
741 /**
742  * @brief Gets pre-configured resize algorithm.
743  * @ingroup Network
744  * @param network A pointer to ie_network_t instance.
745  * @param input_name Name of input data.
746  * @parm resize_alg_result The pointer to the resize algorithm used for input blob creation.
747  * @return Status code of the operation: OK(0) for success.
748  */
749 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_get_input_resize_algorithm(const ie_network_t *network, const char *input_name, \
750  resize_alg_e *resize_alg_result);
751 
752 /**
753  * @brief Sets resize algorithm to be used during pre-processing
754  * @ingroup Network
755  * @param network A pointer to ie_network_t instance.
756  * @param input_name Name of input data.
757  * @param resize_algo Resize algorithm.
758  * @return Status code of the operation: OK(0) for success.
759  */
760 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_set_input_resize_algorithm(ie_network_t *network, const char *input_name, const resize_alg_e resize_algo);
761 
762 /**
763  * @brief Gets color format of the input data.
764  * @ingroup Network
765  * @param network A pointer to ie_network_t instance.
766  * @param input_name Name of input data.
767  * @param colformat_result The pointer to the color format used for input blob creation.
768  * @reutrn Status code of the operation: OK(0) for success.
769  */
770 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_get_color_format(const ie_network_t *network, const char *input_name, colorformat_e *colformat_result);
771 
772 /**
773  * @brief Changes the color format of the input data.
774  * @ingroup Network
775  * @param network A pointer to ie_network_t instance.
776  * @param input_name Name of input data.
777  * @param color_format Color format of the input data.
778  * @reutrn Status code of the operation: OK(0) for success.
779  */
780 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_set_color_format(ie_network_t *network, const char *input_name, const colorformat_e color_format);
781 
782 /**
783  * @brief Helper method collect all input shapes with input names of corresponding input data.
784  * Use the ie_network_input_shapes_free() method to free memory.
785  * @ingroup Network
786  * @param network A pointer to the instance of the ie_network_t to get input shapes.
787  * @param shapes A pointer to the input_shapes.
788  * @return Status code of the operation: OK(0) for success.
789  */
790 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_get_input_shapes(ie_network_t *network, input_shapes_t *shapes);
791 
792 /**
793  * @brief Run shape inference with new input shapes for the network.
794  * @ingroup Network
795  * @param network A pointer to the instance of the ie_network_t to reshape.
796  * @param shapes A new input shapes to set for the network.
797  * @return Status code of the operation: OK(0) for success.
798  */
799 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_reshape(ie_network_t *network, const input_shapes_t shapes);
800 
801 /**
802  * @brief Gets number of output for the network.
803  * @ingroup Network
804  * @param network A pointer to the instance of the ie_network_t to get number of ouput information.
805  * @param size_result A number of the network's output information.
806  * @return Status code of the operation: OK(0) for success.
807  */
808 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_get_outputs_number(const ie_network_t *network, size_t *size_result);
809 
810 /**
811  * @brief Gets name corresponding to the "number". Use the ie_network_name_free() method to free memory.
812  * @ingroup Network
813  * @param network A pointer to theinstance of the ie_network_t to get output information.
814  * @param number An id of output information .
815  * @param name Output name corresponding to the number.
816  * @return Status code of the operation: OK(0) for success.
817  */
818 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_get_output_name(const ie_network_t *network, const size_t number, char **name);
819 
820 /**
821  * @brief Gets a precision of the output data named "output_name".
822  * @ingroup Network
823  * @param network A pointer to ie_network_t instance.
824  * @param output_name Name of output data.
825  * @param prec_result A pointer to the precision used for output blob creation.
826  * @return Status code of the operation: OK(0) for success.
827  */
828 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_get_output_precision(const ie_network_t *network, const char *output_name, precision_e *prec_result);
829 
830 /**
831  * @brief Changes the precision of the output data named "output_name".
832  * @ingroup Network
833  * @param network A pointer to ie_network_t instance.
834  * @param output_name Name of output data.
835  * @param p A new precision of the output data to set (eg. precision_e.FP16).
836  * @return Status code of the operation: OK(0) for success.
837  */
838 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_set_output_precision(ie_network_t *network, const char *output_name, const precision_e p);
839 
840 /**
841  * @brief Gets a layout of the output data.
842  * @ingroup Network
843  * @param network A pointer to ie_network_t instance.
844  * @param output_name Name of output data.
845  * @param layout_result A pointer to the layout used for output blob creation.
846  * @return Status code of the operation: OK(0) for success.
847  */
848 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_get_output_layout(const ie_network_t *network, const char *output_name, layout_e *layout_result);
849 
850 /**
851  * @brief Changes the layout of the output data named "output_name".
852  * @ingroup Network
853  * @param network A pointer to ie_network_t instance.
854  * @param output_name Name of output data.
855  * @param l A new layout of the output data to set.
856  * @return Status code of the operation: OK(0) for success.
857  */
858 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_set_output_layout(ie_network_t *network, const char *output_name, const layout_e l);
859 
860 /**
861  * @brief Gets dimensions/shape of the output data with reversed order.
862  * @ingroup Network
863  * @param network A pointer to ie_network_t instance.
864  * @param output_name Name of output data.
865  * @param dims_result A pointer to the dimensions used for output blob creation.
866  * @return Status code of the operation: OK(0) for success.
867  */
868 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_network_get_output_dims(const ie_network_t *network, const char *output_name, dimensions_t *dims_result);
869 
870 /**
871  * @brief Releases memory occupied by input_shapes.
872  * @ingroup Network
873  * @param inputShapes A pointer to the input_shapes to free memory.
874  */
875 INFERENCE_ENGINE_C_API(void) ie_network_input_shapes_free(input_shapes_t *inputShapes);
876 
877 /**
878  * @brief Releases momory occupied by input_name or output_name.
879  * @ingroup Network
880  * @param name A pointer to the input_name or output_name to free memory.
881  */
882 INFERENCE_ENGINE_C_API(void) ie_network_name_free(char **name);
883 
884 /** @} */ // end of InferRequest
885 
886 // Blob
887 
888 /**
889  * @defgroup Blob Blob
890  * Set of functions allowing to research memory from infer requests or make new
891  * memory objects to be passed to InferRequests.
892  * @{
893  */
894 
895 /**
896  * @brief Creates a blob with the specified dimensions, layout and to allocate memory.
897  * @ingroup Blob
898  * @param tensorDesc Tensor descriptor for Blob creation.
899  * @param blob A pointer to the newly created blob.
900  * @return Status code of the operation: OK(0) for success.
901  */
902 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_blob_make_memory(const tensor_desc_t *tensorDesc, ie_blob_t **blob);
903 
904 /**
905  * @brief Creates a blob with the given tensor descriptor from the pointer to the pre-allocated memory.
906  * @ingroup Blob
907  * @param tensorDesc Tensor descriptor for Blob creation.
908  * @param ptr Pointer to the pre-allocated memory.
909  * @param size Length of the pre-allocated array.
910  * @param blob A pointer to the newly created blob.
911  * @return Status code of the operation: OK(0) for success.
912  */
913 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_blob_make_memory_from_preallocated(const tensor_desc_t *tensorDesc, void *ptr, size_t size, ie_blob_t **blob);
914 
915 /**
916  * @brief Creates a blob describing given roi_t instance based on the given blob with pre-allocated memory.
917  * @ingroup Blob
918  * @param inputBlob original blob with pre-allocated memory.
919  * @param roi A roi_tinstance inside of the original blob.
920  * @param blob A pointer to the newly created blob.
921  * @return Status code of the operation: OK(0) for success.
922  */
923 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_blob_make_memory_with_roi(const ie_blob_t *inputBlob, const roi_t *roi, ie_blob_t **blob);
924 
925 /**
926  * @brief Creates a NV12 blob from two planes Y and UV.
927  * @ingroup Blob
928  * @param y A pointer to the ie_blob_t instance that represents Y plane in NV12 color format.
929  * @param uv A pointer to the ie_blob_t instance that represents UV plane in NV12 color format.
930  * @param nv12Blob A pointer to the newly created blob.
931  * @return Status code of the operation: OK(0) for success.
932 */
933 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_blob_make_memory_nv12(const ie_blob_t *y, const ie_blob_t *uv, ie_blob_t **nv12Blob);
934 
935 /**
936  * @brief Creates I420 blob from three planes Y, U and V.
937  * @ingroup Blob
938  * @param y A pointer to the ie_blob_t instance that represents Y plane in I420 color format.
939  * @param u A pointer to the ie_blob_t instance that represents U plane in I420 color format.
940  * @param v A pointer to the ie_blob_t instance that represents V plane in I420 color format.
941  * @param i420Blob A pointer to the newly created blob.
942  * @return Status code of the operation: OK(0) for success.
943 */
944 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_blob_make_memory_i420(const ie_blob_t *y, const ie_blob_t *u, const ie_blob_t *v, ie_blob_t **i420Blob);
945 
946 /**
947  * @brief Gets the total number of elements, which is a product of all the dimensions.
948  * @ingroup Blob
949  * @param blob A pointer to the blob.
950  * @param size_result The total number of elements.
951  * @return Status code of the operation: OK(0) for success.
952  */
953 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_blob_size(ie_blob_t *blob, int *size_result);
954 
955 /**
956  * @brief Gets the size of the current Blob in bytes.
957  * @ingroup Blob
958  * @param blob A pointer to the blob.
959  * @param bsize_result The size of the current blob in bytes.
960  * @return Status code of the operation: OK(0) for success.
961  */
962 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_blob_byte_size(ie_blob_t *blob, int *bsize_result);
963 
964 /**
965  * @brief Releases previously allocated data
966  * @ingroup Blob
967  * @param blob A pointer to the blob to free memory.
968  */
969 INFERENCE_ENGINE_C_API(void) ie_blob_deallocate(ie_blob_t **blob);
970 
971 /**
972  * @brief Gets access to the allocated memory .
973  * @ingroup Blob
974  * @param blob A pointer to the blob.
975  * @param blob_buffer A pointer to the copied data from the given blob.
976  * @return Status code of the operation: OK(0) for success.
977  */
978 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_blob_get_buffer(const ie_blob_t *blob, ie_blob_buffer_t *blob_buffer);
979 
980 /**
981  * @brief Gets read-only access to the allocated memory.
982  * @ingroup Blob
983  * @param blob A pointer to the blob.
984  * @param blob_cbuffer A pointer to the coped data from the given pointer to the blob and the data is read-only.
985  * @return Status code of the operation: OK(0) for success
986  */
987 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_blob_get_cbuffer(const ie_blob_t *blob, ie_blob_buffer_t *blob_cbuffer);
988 
989 /**
990  * @brief Gets dimensions of blob's tensor.
991  * @ingroup Blob
992  * @param blob A pointer to the blob.
993  * @param dims_result A pointer to the dimensions of blob's tensor.
994  * @return Status code of the operation: OK(0) for success.
995  */
996 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_blob_get_dims(const ie_blob_t *blob, dimensions_t *dims_result);
997 
998 /**
999  * @brief Gets layout of blob's tensor.
1000  * @ingroup Blob
1001  * @param blob A pointer to the blob.
1002  * @param layout_result A pointer to the layout of blob's tensor.
1003  * @return Status code of the operation: OK(0) for success.
1004  */
1005 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_blob_get_layout(const ie_blob_t *blob, layout_e *layout_result);
1006 
1007 /**
1008  * @brief Gets precision of blob's tensor.
1009  * @ingroup Blob
1010  * @param blob A pointer to the blob.
1011  * @param prec_result A pointer to the precision of blob's tensor.
1012  * @return Status code of the operation: OK(0) for success.
1013  */
1014 INFERENCE_ENGINE_C_API(IE_NODISCARD IEStatusCode) ie_blob_get_precision(const ie_blob_t *blob, precision_e *prec_result);
1015 
1016 /**
1017  * @Releases the memory occupied by the ie_blob_t pointer.
1018  * @ingroup Blob
1019  * @param blob A pointer to the blob pointer to release memory.
1020  */
1021 INFERENCE_ENGINE_C_API(void) ie_blob_free(ie_blob_t **blob);
1022 
1023 /** @} */ // end of Blob
1024 
1025 #endif // IE_C_API_H
BIN
@ BIN
Definition: ie_c_api.h:186
FP16
@ FP16
Definition: ie_c_api.h:176
IEStatusCode
IEStatusCode
This enum contains codes for all possible return values of the interface functions.
Definition: ie_c_api.h:228
ie_param_config
Represents configuration parameter information.
Definition: ie_c_api.h:113
roi
Definition: ie_c_api.h:251
ie_core_versions
Represents all versions information that describes all devices and the inference engine runtime libra...
Definition: ie_c_api.h:81
colorformat_e
colorformat_e
Extra information about input color format for preprocessing.
Definition: ie_c_api.h:204
dimensions
Represents dimensions for input or output data.
Definition: ie_c_api.h:130
resize_alg_e
resize_alg_e
Represents the list of supported resize algorithms.
Definition: ie_c_api.h:218
RGB
@ RGB
RGB color format.
Definition: ie_c_api.h:206
ie_blob_buffer
Represents copied data from the given blob.
Definition: ie_c_api.h:281
Q78
@ Q78
Definition: ie_c_api.h:177
RAW
@ RAW
Plain blob (default), no extra color processing required.
Definition: ie_c_api.h:205
input_shape
Represents shape for input data.
Definition: ie_c_api.h:263
I420
@ I420
I420 color format represented as compound Y+U+V blob.
Definition: ie_c_api.h:211
BGRX
@ BGRX
BGRX color format with X ignored during inference.
Definition: ie_c_api.h:209
ie_version
Represents an API version information that reflects the set of supported features.
Definition: ie_c_api.h:61
BGR
@ BGR
BGR color format, default in DLDT.
Definition: ie_c_api.h:207
CUSTOM
@ CUSTOM
Definition: ie_c_api.h:187
UNSPECIFIED
@ UNSPECIFIED
Definition: ie_c_api.h:173
NV12
@ NV12
NV12 color format represented as compound Y+UV blob.
Definition: ie_c_api.h:210
ie_core_version
Represents version information that describes devices and the inference engine runtime library.
Definition: ie_c_api.h:69
RGBX
@ RGBX
RGBX color format with X ignored during inference.
Definition: ie_c_api.h:208
tensor_desc
Represents detailed information for a tensor.
Definition: ie_c_api.h:194
input_shapes
Represents shapes for all input data.
Definition: ie_c_api.h:272
U64
@ U64
Definition: ie_c_api.h:184
I32
@ I32
Definition: ie_c_api.h:182
MIXED
@ MIXED
Definition: ie_c_api.h:174
ie_complete_call_back
Completion callback definition about the function and args.
Definition: ie_c_api.h:292
FP32
@ FP32
Definition: ie_c_api.h:175
I64
@ I64
Definition: ie_c_api.h:183
U16
@ U16
Definition: ie_c_api.h:181
U32
@ U32
Definition: ie_c_api.h:185
desc
Represents detailed information for an error.
Definition: ie_c_api.h:122
ie_config
Represents configuration information that describes devices.
Definition: ie_c_api.h:90
I16
@ I16
Definition: ie_c_api.h:178
ie_available_devices
Represent all available devices.
Definition: ie_c_api.h:301
I8
@ I8
Definition: ie_c_api.h:180
U8
@ U8
Definition: ie_c_api.h:179
layout_e
layout_e
Layouts that the inference engine supports.
Definition: ie_c_api.h:139
precision_e
precision_e
Precisions that the inference engine supports.
Definition: ie_c_api.h:172
roi_t
This structure describes roi data.
ie_param
metric and config parameters.
Definition: ie_c_api.h:100