1 // Copyright (C) 2018 Intel Corporation
3 // SPDX-License-Identifier: Apache-2.0
7 * @brief This header file defines the main Data representation node.
16 #include "ie_common.h"
17 #include "details/ie_exception.hpp"
18 #include "ie_precision.hpp"
19 #include "ie_layouts.h"
22 namespace InferenceEngine {
24 * @brief This class represents the main Data representation node.
26 * The NN graphs are di-graphs consisting of data nodes and layer nodes.
28 class INFERENCE_ENGINE_API_CLASS(Data) {
31 * @deprecated Deprecated. Please use getPrecision()
32 * @brief A precision type of this Data instance
36 * @deprecated Deprecated. Please use getFormat()
37 * @brief A data layout of this Data instance
41 * @deprecated Deprecated. Please use getDims()
42 * @brief A tensor dimension array (the order is opposite to the order in the IR: w,h,c,n) of this Data instance
46 * @deprecated Deprecated. Please use getCreatorLayer()
47 * @brief A pointer to the layer that creates this data element, null for input data elements
49 CNNLayerWeakPtr creatorLayer;
51 * @deprecated Deprecated. Please use getName()
52 * @brief A unique name that identifies this data node
56 * @deprecated Deprecated. Please use getInputTo()
57 * @brief A map of layers that use this node as input.
58 * It is useful for recursive NN graph traversal.
60 std::map<std::string, CNNLayerPtr> inputTo;
62 * @deprecated Deprecated. Please use getUserObject()
63 * @brief A user utility place holder
68 * @brief An empty constructor (dimensionless)
69 * @param name Name of the data node
70 * @param _precision Precision of the data
72 Data(const std::string &name, Precision _precision, Layout layout = NCHW);
75 * @brief A full constructor (with dimensions)
76 * @param name Name of the data node
77 * @param a_dims Data tensor dimensions
78 * @param _precision Precision of the data
80 Data(const std::string &name, const SizeVector &a_dims, Precision _precision, Layout layout = NCHW);
82 * @brief A constructor with tensor descriptor
83 * @param name Name of the data node
84 * @param desc Tensor descriptor
86 Data(const std::string &name, const TensorDesc& desc);
89 * @brief Checks if the current node is resolved
90 * @return true if resolved, false otherwise.
92 bool isInitialized() const;
95 * @brief Sets the data dimensions.
96 * After the current node is marked as resolved.
97 * @param a_dims Tensor dimensions to set
99 void setDims(const SizeVector &a_dims);
103 * @brief Sets the batch value in the data dimensions.
104 * Batch is defined as the last element in the dimensions vector.
105 * @param batch_size Batch size to set
107 inline void setBatchSize(size_t batch_size);
110 * @brief Sets the layout value for this Data instance
111 * @param layout Layout value to set
113 void setLayout(Layout layout);
116 * @brief Gets the layout value for this Data instance
118 Layout getLayout() const;
121 * @brief Gets Tensor descriptor reference
122 @return reference to TensorDesc
124 const TensorDesc& getTensorDesc() const;
127 * @brief Gets a precision type of this Data instance
128 * @return Precision type
130 const Precision& getPrecision() const;
133 * @brief Gets a precision type of this Data instance
134 * @return Precision type
136 void setPrecision(const Precision& precision);
139 * @return data dimensions
141 const SizeVector& getDims() const;
144 * @return owner of this data layer, parent layer in di-graph
146 CNNLayerWeakPtr& getCreatorLayer();
149 * @return name of the data object
151 const std::string& getName() const;
154 * @brief returns child layers in di-graph
156 std::map<std::string, CNNLayerPtr>& getInputTo();
159 * @return convenient arbitrary user data holder
161 const UserValue& getUserObject() const;
163 TensorDesc tensorDesc;
165 } // namespace InferenceEngine