1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * @brief This header file defines the main Data representation node.
17 #include "details/ie_exception.hpp"
19 #include "ie_common.h"
20 #include "ie_layouts.h"
21 #include "ie_precision.hpp"
23 namespace InferenceEngine {
25 * @brief This class represents the main Data representation node.
27 * The NN graphs are di-graphs consisting of data nodes and layer nodes.
30 class INFERENCE_ENGINE_API_CLASS(Data) {
33 * @brief An empty constructor (dimensionless)
35 * @param name Name of the data node
36 * @param _precision Precision of the data
37 * @param layout Data layout
39 Data(const std::string& name, Precision _precision, Layout layout = NCHW);
42 * @deprecated Use Data(const std::string &name, const TensorDesc& desc)
43 * @brief A full constructor (with dimensions)
45 * @param name Name of the data node
46 * @param a_dims Data tensor dimensions
47 * @param _precision Precision of the data
48 * @param layout Data layout
50 INFERENCE_ENGINE_DEPRECATED("Use Data(const std::string &name, const TensorDesc& desc) as a replacement."
51 "The ctor will be removed in 2020 R2")
52 Data(const std::string& name, const SizeVector& a_dims, Precision _precision, Layout layout = NCHW);
54 * @brief A constructor with tensor descriptor
56 * @param name Name of the data node
57 * @param desc Tensor descriptor
59 Data(const std::string& name, const TensorDesc& desc);
62 * @brief A virtual destructor
64 virtual ~Data() = default;
67 * @brief Checks if the current node is resolved
69 * @return true if resolved, false otherwise.
71 bool isInitialized() const;
74 * @brief Sets the data dimensions.
76 * After the current node is marked as resolved.
78 * @param a_dims Tensor dimensions to set
80 void setDims(const SizeVector& a_dims);
83 * @brief Sets the layout value for this Data instance
85 * @param layout Layout value to set
87 void setLayout(Layout layout);
90 * @brief changes dims and layout at same time
92 * @param dims new dimensions
93 * @param layout new layout
95 void reshape(const SizeVector& dims, Layout layout);
98 * @brief Gets the layout value for this Data instance
100 Layout getLayout() const;
103 * @brief Gets Tensor descriptor reference
105 * @return reference to TensorDesc
107 const TensorDesc& getTensorDesc() const;
110 * @brief Gets a precision type of this Data instance
112 * @return Precision type
114 const Precision& getPrecision() const;
117 * @brief Sets a precision type of this Data instance
119 * @param precision Precision of the data
121 void setPrecision(const Precision& precision);
124 * @return data dimensions
126 const SizeVector& getDims() const;
129 * @return owner of this data layer, parent layer in di-graph
131 virtual CNNLayerWeakPtr& getCreatorLayer();
134 * @return name of the data object
136 const std::string& getName() const;
139 * @brief Sets a name the Data object
141 * @param newName Name of the data node
144 void setName(const std::string& newName);
147 * @brief returns child layers in di-graph
149 virtual std::map<std::string, CNNLayerPtr>& getInputTo();
152 * @return convenient arbitrary user data holder
154 const UserValue& getUserObject() const;
158 * @brief A pointer to the layer that creates this data element, null for input data elements
160 CNNLayerWeakPtr creatorLayer;
163 * @brief A unique name that identifies this data node
168 * @brief A map of layers that use this node as input.
169 * It is useful for recursive NN graph traversal.
171 std::map<std::string, CNNLayerPtr> inputTo;
174 * @brief A user utility place holder
176 UserValue userObject;
179 * @brief A tensor descriptor
181 mutable TensorDesc tensorDesc;
183 } // namespace InferenceEngine