ie_icnn_net_reader.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  * @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  * @deprecated Use InferenceEngine::Core::ReadNetwork methods. This API will be removed in 2021.1
24  * @brief This class is the main interface to build and parse a network from a given IR
25  *
26  * All methods here do not throw exceptions and return a StatusCode and ResponseDesc object.
27  * Alternatively, to use methods that throw exceptions, refer to the CNNNetReader wrapper class.
28  */
29 class INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::Core::ReadNetwork methods. This API will be removed in 2021.1")
30  ICNNNetReader : public details::IRelease {
31 public:
32  /**
33  * @brief Parses the topology part of the IR (.xml)
34  *
35  * This method can be called once only to read network. If you need to read another network instance then create new
36  * reader instance.
37  *
38  * @param filepath The full path to the .xml file of the IR
39  * @param resp Response message
40  * @return Result code
41  */
42  virtual StatusCode ReadNetwork(const char* filepath, ResponseDesc* resp) noexcept = 0;
43 
44  /**
45  * @brief Parses the topology part of the IR (.xml) given the xml as a buffer
46  *
47  * This method can be called once only to read network. If you need to read another network instance then create new
48  * reader instance.
49  *
50  * @param model Pointer to a char array with the IR
51  * @param resp Response message
52  * @param size Size of the char array in bytes
53  * @return Result code
54  */
55  virtual StatusCode ReadNetwork(const void* model, size_t size, ResponseDesc* resp) noexcept = 0;
56 
57  /**
58  * @brief Sets the weights buffer (.bin part) from the IR.
59  *
60  * Weights Blob must always be of bytes - the casting to precision is done per-layer to support mixed
61  * networks and to ease of use.
62  * This method can be called more than once to reflect updates in the .bin.
63  *
64  * @param weights Blob of bytes that holds all the IR binary data
65  * @param resp Response message
66  * @return Result code
67  */
68  virtual StatusCode SetWeights(const TBlob<uint8_t>::Ptr& weights, ResponseDesc* resp) noexcept = 0;
69 
70  /**
71  * @brief Loads and sets the weights buffer directly from the IR .bin file.
72  *
73  * This method can be called more than once to reflect updates in the .bin.
74  *
75  * @param filepath Full path to the .bin file
76  * @param resp Response message
77  * @return Result code
78  */
79  virtual StatusCode ReadWeights(const char* filepath, ResponseDesc* resp) noexcept = 0;
80 
81  /**
82  * @brief Returns a pointer to the built network
83  *
84  * @param resp Response message
85  * @return A pointer to a network
86  */
87  virtual ICNNNetwork* getNetwork(ResponseDesc* resp) noexcept = 0;
88 
89  /**
90  * @brief Retrieves the last building status
91  * @param resp Response message
92  * @return `True` in case of parsing is successful, `false` otherwise.
93  */
94  virtual bool isParseSuccess(ResponseDesc* resp) noexcept = 0;
95 
96  /**
97  * @brief Retrieves the last building failure message if failed
98  *
99  * @param resp Response message
100  * @return StatusCode that indicates the network status
101  */
102  virtual StatusCode getDescription(ResponseDesc* resp) noexcept = 0;
103 
104  /**
105  * @brief Gets network name
106  *
107  * @param name Pointer to preallocated buffer that receives network name
108  * @param len Length of the preallocated buffer, network name will be trimmed by this lenght
109  * @param resp Response message
110  * @return Result code
111  */
112  virtual StatusCode getName(char* name, size_t len, ResponseDesc* resp) noexcept = 0;
113 
114  /**
115  * @brief Returns a version of IR
116  *
117  * @param resp Response message
118  * @return IR version number: 1 or 2
119  */
120  virtual int getVersion(ResponseDesc* resp) noexcept = 0;
121 };
122 
123 /**
124  * @brief Creates a CNNNetReader instance
125  *
126  * @return An object that implements the ICNNNetReader interface
127  */
128 IE_SUPPRESS_DEPRECATED_START
129 INFERENCE_ENGINE_API(ICNNNetReader*) CreateCNNNetReader() noexcept;
130 IE_SUPPRESS_DEPRECATED_END
131 } // namespace InferenceEngine
Inference Engine API.
Definition: ie_argmax_layer.hpp:15
CNNNetwork ReadNetwork(const std::string &modelPath, const std::string &binPath="") const
Reads IR xml and bin files.
std::string name
Layer name.
Definition: ie_layers.h:42
A header file for Blob and generic TBlob<>
This is a header file for the ICNNNetwork class.
This class is the main interface to build and parse a network from a given IR.
Definition: ie_icnn_net_reader.h:29
ICNNNetReader * CreateCNNNetReader() noexcept
Creates a CNNNetReader instance.
Represents detailed information for an error.
Definition: ie_common.h:247
std::shared_ptr< TBlob< T >> Ptr
Smart Pointer to this TBlob object.
Definition: ie_blob.h:478
StatusCode
This enum contains codes for all possible return values of the interface functions.
Definition: ie_common.h:224
This is the main interface to describe the NN topology.
Definition: ie_icnn_network.hpp:43
The macro defines a symbol import/export mechanism essential for Microsoft Windows(R) OS...
header file for no_copy class
This is a header file with common inference engine definitions.