Publishing 2020.1 content
[platform/upstream/dldt.git] / inference-engine / include / ie_icnn_net_reader.h
1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 /**
6  * @brief A header file that provides interface for network reader that is used to build networks from a given IR
7  *
8  * @file ie_icnn_net_reader.h
9  */
10 #pragma once
11
12 #include <map>
13 #include <string>
14
15 #include "details/ie_no_copy.hpp"
16 #include "ie_api.h"
17 #include "ie_blob.h"
18 #include "ie_common.h"
19 #include "ie_icnn_network.hpp"
20
21 namespace InferenceEngine {
22 /**
23  * @brief This class is the main interface to build and parse a network from a given IR
24  *
25  * All methods here do not throw exceptions and return a StatusCode and ResponseDesc object.
26  * Alternatively, to use methods that throw exceptions, refer to the CNNNetReader wrapper class.
27  */
28 class INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::Core::ReadNetwork() method this API will be removed in 2020 R2")
29     ICNNNetReader : public details::IRelease {
30 public:
31     /**
32      * @brief Parses the topology part of the IR (.xml)
33      *
34      * This method can be called once only to read network. If you need to read another network instance then create new
35      * reader instance.
36      *
37      * @param filepath The full path to the .xml file of the IR
38      * @param resp Response message
39      * @return Result code
40      */
41     virtual StatusCode ReadNetwork(const char* filepath, ResponseDesc* resp) noexcept = 0;
42
43     /**
44      * @brief Parses the topology part of the IR (.xml) given the xml as a buffer
45      *
46      * This method can be called once only to read network. If you need to read another network instance then create new
47      * reader instance.
48      *
49      * @param model Pointer to a char array with the IR
50      * @param resp Response message
51      * @param size Size of the char array in bytes
52      * @return Result code
53      */
54     virtual StatusCode ReadNetwork(const void* model, size_t size, ResponseDesc* resp) noexcept = 0;
55
56     /**
57      * @brief Sets the weights buffer (.bin part) from the IR.
58      *
59      * Weights Blob must always be of bytes - the casting to precision is done per-layer to support mixed
60      * networks and to ease of use.
61      * This method can be called more than once to reflect updates in the .bin.
62      *
63      * @param weights Blob of bytes that holds all the IR binary data
64      * @param resp Response message
65      * @return Result code
66      */
67     virtual StatusCode SetWeights(const TBlob<uint8_t>::Ptr& weights, ResponseDesc* resp) noexcept = 0;
68
69     /**
70      * @brief Loads and sets the weights buffer directly from the IR .bin file.
71      *
72      * This method can be called more than once to reflect updates in the .bin.
73      *
74      * @param filepath Full path to the .bin file
75      * @param resp Response message
76      * @return Result code
77      */
78     virtual StatusCode ReadWeights(const char* filepath, ResponseDesc* resp) noexcept = 0;
79
80     /**
81      * @brief Returns a pointer to the built network
82      *
83      * @param resp Response message
84      */
85     virtual ICNNNetwork* getNetwork(ResponseDesc* resp) noexcept = 0;
86
87     /**
88      * @brief Retrieves the last building status
89      *
90      * @param resp Response message
91      */
92     virtual bool isParseSuccess(ResponseDesc* resp) noexcept = 0;
93
94     /**
95      * @brief Retrieves the last building failure message if failed
96      *
97      * @param resp Response message
98      * @return StatusCode that indicates the network status
99      */
100     virtual StatusCode getDescription(ResponseDesc* resp) noexcept = 0;
101
102     /**
103      * @brief Gets network name
104      *
105      * @param name Pointer to preallocated buffer that receives network name
106      * @param len Length of the preallocated buffer, network name will be trimmed by this lenght
107      * @param resp Response message
108      * @return Result code
109      */
110     virtual StatusCode getName(char* name, size_t len, ResponseDesc* resp) noexcept = 0;
111
112     /**
113      * @brief Returns a version of IR
114      *
115      * @param resp Response message
116      * @return IR version number: 1 or 2
117      */
118     virtual int getVersion(ResponseDesc* resp) noexcept = 0;
119 };
120
121 /**
122  * @brief Creates a CNNNetReader instance
123  *
124  * @return An object that implements the ICNNNetReader interface
125  */
126 IE_SUPPRESS_DEPRECATED_START
127 INFERENCE_ENGINE_API(ICNNNetReader*) CreateCNNNetReader() noexcept;
128 IE_SUPPRESS_DEPRECATED_END
129 }  // namespace InferenceEngine