1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * @brief a header file for InputInfo class
8 * @file ie_input_info.hpp
17 #include "ie_common.h"
19 #include "ie_precision.hpp"
20 #include "ie_preprocess.hpp"
22 namespace InferenceEngine {
25 * @brief This class contains information about each input of the network
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>;
35 * @brief Gets a precision of the input data provided by user
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
41 * @details By default it matches the layers precision, but there are exceptions of this rule.
42 * For Q78 precision networks the input is expected in I16 by default.
43 * For FP16 precision networks the input is expected in FP32 by default.
44 * The default input precision might be changed preferred one using InputInfo::setPrecision()
46 * For example, for a Q78 precision network you can pass FP32 input data
47 * @return The precision used for input blob creation
49 Precision getPrecision() const {
51 THROW_IE_EXCEPTION << "Data is empty!";
53 return _inputData->getPrecision();
57 * @brief Changes the precision of the input data provided by the user.
59 * This function should be called before loading the network to the plugin
60 * @param p A new precision of the input data to set
62 void setPrecision(Precision p) {
64 THROW_IE_EXCEPTION << "Data is empty!";
66 _inputData->setPrecision(p);
70 * @brief Gets a layout of the input data provided by user
72 * @details By default it matches the layers precision and depends on number of its dimensions:
73 * C - for 1-dimensional,
74 * NC - for 2-dimensional,
75 * CHW - for 3-dimensional,
76 * NCHW - for 4-dimensional
77 * The default input layout might be changed preferred one using setLayout() function.
78 * @return The precision used for input blob creation
82 THROW_IE_EXCEPTION << "Data is empty!";
84 return _inputData->getLayout();
88 * @brief Changes the layout of the input data provided by the user.
90 * This function should be called before loading the network to the plugin
91 * @param p A new layout of the input data to set
93 void setLayout(Layout l) {
95 THROW_IE_EXCEPTION << "Data is empty!";
97 _inputData->setLayout(l);
101 * @brief Gets the name of the input
103 * @return A string - the name of the input
105 const std::string& name() const {
106 return _inputData->getName();
110 * @brief Gets the input data
112 * @return A smart pointer to the input data
114 DataPtr getInputData() const {
119 * @brief Initializes the pointer to the input data that stores the main input parameters like dims, etc.
121 * This method initializes the precision with the information from the inputPtr if it was not set
122 * explicitly through InputInfo::setPrecision. If InputInfo::setPrecision is called, this method does not overwrite
124 * @param inputPtr Pointer to the input data to set
126 void setInputData(DataPtr inputPtr) {
127 _inputData = inputPtr;
131 * @brief Returns the tensor descriptor
133 const TensorDesc& getTensorDesc() const {
135 THROW_IE_EXCEPTION << "Data is empty!";
137 return _inputData->getTensorDesc();
141 * @brief Gets pre-process info for the input
143 * @return A reference to the PreProcessInfo instance that contains pre-process info for this input
145 PreProcessInfo& getPreProcess() {
146 return _preProcessInfo;
151 * @brief Pre-process info for the input
153 PreProcessInfo _preProcessInfo;
156 * @brief A smart pointer to the input data
162 * @brief A collection that contains string as key, and InputInfo smart pointer as value
164 using InputsDataMap = std::map<std::string, InputInfo::Ptr>;
167 * @brief A collection that contains string as key, and const InputInfo smart pointer as value
169 using ConstInputsDataMap = std::map<std::string, InputInfo::CPtr>;
171 } // namespace InferenceEngine