1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * @brief This header file defines the main Data representation node.
15 #include "ie_common.h"
16 #include "details/ie_exception.hpp"
17 #include "ie_precision.hpp"
18 #include "ie_layouts.h"
21 namespace InferenceEngine {
23 * @brief This class represents the main Data representation node.
25 * The NN graphs are di-graphs consisting of data nodes and layer nodes.
27 class INFERENCE_ENGINE_API_CLASS(Data) {
30 * @brief An empty constructor (dimensionless)
31 * @param name Name of the data node
32 * @param _precision Precision of the data
33 * @param layout Data layout
35 Data(const std::string &name, Precision _precision, Layout layout = NCHW);
38 * @deprecated Use Data(const std::string &name, const TensorDesc& desc)
39 * @brief A full constructor (with dimensions)
40 * @param name Name of the data node
41 * @param a_dims Data tensor dimensions
42 * @param _precision Precision of the data
43 * @param layout Data layout
45 INFERENCE_ENGINE_DEPRECATED
46 Data(const std::string &name, const SizeVector &a_dims, Precision _precision, Layout layout = NCHW);
48 * @brief A constructor with tensor descriptor
49 * @param name Name of the data node
50 * @param desc Tensor descriptor
52 Data(const std::string &name, const TensorDesc& desc);
55 * @brief Checks if the current node is resolved
56 * @return true if resolved, false otherwise.
58 bool isInitialized() const;
61 * @brief Sets the data dimensions.
62 * After the current node is marked as resolved.
63 * @param a_dims Tensor dimensions to set
65 void setDims(const SizeVector &a_dims);
68 * @brief Sets the layout value for this Data instance
69 * @param layout Layout value to set
71 void setLayout(Layout layout);
74 * @brief changes dims and layout at same time
75 * @param dims new dimensions
76 * @param layout new layout
78 void reshape(const SizeVector &dims, Layout layout);
81 * @brief Gets the layout value for this Data instance
83 Layout getLayout() const;
86 * @brief Gets Tensor descriptor reference
87 @return reference to TensorDesc
89 const TensorDesc& getTensorDesc() const;
92 * @brief Gets a precision type of this Data instance
93 * @return Precision type
95 const Precision& getPrecision() const;
98 * @brief Sets a precision type of this Data instance
99 * @param precision Precision of the data
101 void setPrecision(const Precision& precision);
104 * @return data dimensions
106 const SizeVector& getDims() const;
109 * @return owner of this data layer, parent layer in di-graph
111 CNNLayerWeakPtr& getCreatorLayer();
114 * @return name of the data object
116 const std::string& getName() const;
120 * @brief Sets a name the Data object
121 * @param newName Name of the data node
124 void setName(const std::string& newName);
127 * @brief returns child layers in di-graph
129 std::map<std::string, CNNLayerPtr>& getInputTo();
132 * @return convenient arbitrary user data holder
134 const UserValue& getUserObject() const;
137 * @brief A pointer to the layer that creates this data element, null for input data elements
139 CNNLayerWeakPtr creatorLayer;
142 * @brief A unique name that identifies this data node
147 * @brief A map of layers that use this node as input.
148 * It is useful for recursive NN graph traversal.
150 std::map<std::string, CNNLayerPtr> inputTo;
153 * @brief A user utility place holder
155 UserValue userObject;
158 * @brief A tensor descriptor
160 mutable TensorDesc tensorDesc;
162 } // namespace InferenceEngine