1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * @brief a header file for InputInfo class
7 * @file ie_input_info.hpp
14 #include "ie_common.h"
16 #include "ie_preprocess.hpp"
18 #include "ie_precision.hpp"
20 namespace InferenceEngine {
23 * @brief This class contains information about each input of the network
27 /** @brief A smart pointer to the InputInfo instance */
28 using Ptr = std::shared_ptr<InputInfo>;
29 /** @brief A smart pointer to the constant InputInfo instance */
30 using CPtr = std::shared_ptr<const InputInfo>;
33 * @deprecated it will be removed from public API. Please use getPrecision()
34 * @brief Gets a precision of the input data provided by user
36 * By default it matches the layers precision, but there are exceptions of this rule
37 * For Q78 precision networks the input is expected in I16 by default
38 * For FP16 precision networks the input is expected in FP32 by default
40 * @details By default it matches the layers precision, but there are exceptions of this rule.
41 * For Q78 precision networks the input is expected in I16 by default.
42 * For FP16 precision networks the input is expected in FP32 by default.
43 * The default input precision might be changed preferred one using setInputPrecision()
45 * For example, for a Q78 precision network you can pass FP32 input data
46 * @return The precision used for input blob creation
48 Precision getInputPrecision() const {
49 return getPrecision();
53 * @deprecated it will be removed from public API. Please use setPrecision()
54 * @brief Changes the precision of the input data provided by the user.
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
58 void setInputPrecision(Precision p) {
63 * @brief Gets a precision of the input data provided by user
65 * By default it matches the layers precision, but there are exceptions of this rule
66 * For Q78 precision networks the input is expected in I16 by default
67 * For FP16 precision networks the input is expected in FP32 by default
69 * @details By default it matches the layers precision, but there are exceptions of this rule.
70 * For Q78 precision networks the input is expected in I16 by default.
71 * For FP16 precision networks the input is expected in FP32 by default.
72 * The default input precision might be changed preferred one using setInputPrecision()
74 * For example, for a Q78 precision network you can pass FP32 input data
75 * @return The precision used for input blob creation
77 Precision getPrecision() const {
79 THROW_IE_EXCEPTION << "Data is empty!";
81 return _inputData->getPrecision();
85 * @brief Changes the precision of the input data provided by the user.
86 * This function should be called before loading the network to the plugin
87 * @param p A new precision of the input data to set
89 void setPrecision(Precision p) {
91 THROW_IE_EXCEPTION << "Data is empty!";
93 _inputData->setPrecision(p);
97 * @brief Gets a layout of the input data provided by user
98 * @details By default it matches the layers precision and depends on number of its dimensions:
99 * C - for 1-dimensional,
100 * NC - for 2-dimensional,
101 * CHW - for 3-dimensional,
102 * NCHW - for 4-dimensional
103 * The default input layout might be changed preferred one using setLayout() function.
104 * @return The precision used for input blob creation
108 THROW_IE_EXCEPTION << "Data is empty!";
110 return _inputData->getLayout();
114 * @brief Changes the layout of the input data provided by the user.
115 * This function should be called before loading the network to the plugin
116 * @param p A new layout of the input data to set
118 void setLayout(Layout l) {
120 THROW_IE_EXCEPTION << "Data is empty!";
122 _inputData->setLayout(l);
126 * @brief Gets the name of the input
127 * @return A string - the name of the input
129 const std::string &name() const { return _inputData->getName(); }
132 * @brief Gets the input data
133 * @return A smart pointer to the input data
135 DataPtr getInputData() {
140 * @brief Initializes the pointer to the input data that stores the main input parameters like dims, etc.
141 * This method initializes the precision with the information from the inputPtr if it was not set
142 * explicitly through setInputPrecision(). If setInputPrecision() was called, this method does not overwrite the precision.
143 * @param inputPtr Pointer to the input data to set
145 void setInputData(DataPtr inputPtr) {
146 _inputData = inputPtr;
150 * @deprecated Please use getTensorDesc for working with layouts and dimensions
151 * @brief Gets dimensions/shape of the input data with reversed order
152 * @return A SizeVector object that contains dimensions of the input data. If the data is not set, the method returns an empty SizeVector object.
154 SizeVector getDims() const {
156 return _inputData->dims;
163 * @brief Returns the tensor descriptor
165 const TensorDesc &getTensorDesc() const {
167 THROW_IE_EXCEPTION << "Data is empty!";
169 return _inputData->getTensorDesc();
173 * @brief Gets pre-process info for the input
174 * @return A reference to the PreProcessInfo instance that contains pre-process info for this input
176 PreProcessInfo &getPreProcess() { return _preProcessInfo; }
180 * @brief Pre-process info for the input
182 PreProcessInfo _preProcessInfo;
185 * @brief A smart pointer to the input data
191 * @brief A collection that contains string as key, and InputInfo smart pointer as value
193 using InputsDataMap = std::map<std::string, InputInfo::Ptr>;
196 * @brief A collection that contains string as key, and const InputInfo smart pointer as value
198 using ConstInputsDataMap = std::map<std::string, InputInfo::CPtr>;
200 } // namespace InferenceEngine