Removed Int8 normalizer and statistics (#919)
[platform/upstream/dldt.git] / inference-engine / include / ie_input_info.hpp
1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 /**
6  * @brief a header file for InputInfo class
7  *
8  * @file ie_input_info.hpp
9  */
10 #pragma once
11
12 #include <map>
13 #include <memory>
14 #include <string>
15
16 #include "ie_blob.h"
17 #include "ie_common.h"
18 #include "ie_data.h"
19 #include "ie_precision.hpp"
20 #include "ie_preprocess.hpp"
21
22 namespace InferenceEngine {
23
24 /**
25  * @brief This class contains information about each input of the network
26  */
27 class InputInfo {
28 public:
29     /** @brief A smart pointer to the InputInfo instance */
30     using Ptr = std::shared_ptr<InputInfo>;
31     /** @brief A smart pointer to the constant InputInfo instance */
32     using CPtr = std::shared_ptr<const InputInfo>;
33
34     /**
35      * @brief Gets a precision of the input data provided by user
36      *
37      * By default it matches the layers precision, but there are exceptions of this rule
38      * For Q78 precision networks the input is expected in I16 by default
39      * For FP16 precision networks the input is expected in FP32 by default
40      * The default input precision might be changed preferred one using InputInfo::setPrecision()
41      * function.
42      * For example, for a Q78 precision network you can pass FP32 input data
43      * @return The precision used for input blob creation
44      */
45     Precision getPrecision() const {
46         if (!_inputData) {
47             THROW_IE_EXCEPTION << "Data is empty!";
48         }
49         return _inputData->getPrecision();
50     }
51
52     /**
53      * @brief Changes the precision of the input data provided by the user.
54      *
55      * This function should be called before loading the network to the plugin
56      * @param p A new precision of the input data to set
57      */
58     void setPrecision(Precision p) {
59         if (!_inputData) {
60             THROW_IE_EXCEPTION << "Data is empty!";
61         }
62         _inputData->setPrecision(p);
63     }
64
65     /**
66      * @brief Gets a layout of the input data provided by user
67      *
68      * @details By default it matches the layers precision and depends on number of its dimensions:
69      * C - for 1-dimensional,
70      * NC - for 2-dimensional,
71      * CHW - for 3-dimensional,
72      * NCHW - for 4-dimensional
73      * The default input layout might be changed preferred one using setLayout() function.
74      * @return The precision used for input blob creation
75      */
76     Layout getLayout() {
77         if (!_inputData) {
78             THROW_IE_EXCEPTION << "Data is empty!";
79         }
80         return _inputData->getLayout();
81     }
82
83     /**
84      * @brief Changes the layout of the input data provided by the user.
85      *
86      * This function should be called before loading the network to the plugin
87      * @param l A new layout of the input data to set
88      */
89     void setLayout(Layout l) {
90         if (!_inputData) {
91             THROW_IE_EXCEPTION << "Data is empty!";
92         }
93         _inputData->setLayout(l);
94     }
95
96     /**
97      * @brief Gets the name of the input
98      *
99      * @return A string - the name of the input
100      */
101     const std::string& name() const {
102         return _inputData->getName();
103     }
104
105     /**
106      * @brief Gets the input data
107      *
108      * @return A smart pointer to the input data
109      */
110     DataPtr getInputData() const {
111         return _inputData;
112     }
113
114     /**
115      * @brief Initializes the pointer to the input data that stores the main input parameters like dims, etc
116      *
117      * This method initializes the precision with the information from the inputPtr if it was not set
118      * explicitly through InputInfo::setPrecision. If InputInfo::setPrecision is called, this method does not overwrite
119      * the precision.
120      * @param inputPtr Pointer to the input data to set
121      */
122     void setInputData(DataPtr inputPtr) {
123         _inputData = inputPtr;
124     }
125
126     /**
127      * @brief Returns the tensor descriptor
128      */
129     const TensorDesc& getTensorDesc() const {
130         if (!_inputData) {
131             THROW_IE_EXCEPTION << "Data is empty!";
132         }
133         return _inputData->getTensorDesc();
134     }
135
136     /**
137      * @brief Gets pre-process info for the input
138      *
139      * @return A reference to the PreProcessInfo instance that contains pre-process info for this input
140      */
141     PreProcessInfo& getPreProcess() {
142         return _preProcessInfo;
143     }
144
145 protected:
146     /**
147      * @brief Pre-process info for the input
148      */
149     PreProcessInfo _preProcessInfo;
150
151     /**
152      * @brief A smart pointer to the input data
153      */
154     DataPtr _inputData;
155 };
156
157 /**
158  * @brief A collection that contains string as key, and InputInfo smart pointer as value
159  */
160 using InputsDataMap = std::map<std::string, InputInfo::Ptr>;
161
162 /**
163  * @brief A collection that contains string as key, and const InputInfo smart pointer as value
164  */
165 using ConstInputsDataMap = std::map<std::string, InputInfo::CPtr>;
166
167 }  // namespace InferenceEngine