updated readme file due to moving CMake scripts to the root folder
[platform/upstream/dldt.git] / inference-engine / include / ie_data.h
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 /**
6  * @brief This header file defines the main Data representation node.
7  * @file ie_data.h
8  */
9 #pragma once
10
11 #include <map>
12 #include <memory>
13 #include <vector>
14 #include "ie_api.h"
15 #include "ie_common.h"
16 #include "details/ie_exception.hpp"
17 #include "ie_precision.hpp"
18 #include "ie_layouts.h"
19 #include <string>
20
21 namespace InferenceEngine {
22 /**
23  * @brief This class represents the main Data representation node.
24  *
25  * The NN graphs are di-graphs consisting of data nodes and layer nodes.
26  */
27 class INFERENCE_ENGINE_API_CLASS(Data) {
28 public:
29     /**
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
34      */
35     Data(const std::string &name, Precision _precision, Layout layout = NCHW);
36
37     /**
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
44      */
45     INFERENCE_ENGINE_DEPRECATED
46     Data(const std::string &name, const SizeVector &a_dims, Precision _precision, Layout layout = NCHW);
47     /**
48      * @brief A constructor with tensor descriptor
49      * @param name Name of the data node
50      * @param desc Tensor descriptor
51      */
52     Data(const std::string &name, const TensorDesc& desc);
53
54     /**
55      * @brief Checks if the current node is resolved
56      * @return true if resolved, false otherwise.
57      */
58     bool isInitialized() const;
59
60     /**
61      * @brief Sets the data dimensions.
62      * After the current node is marked as resolved.
63      * @param a_dims Tensor dimensions to set
64      */
65     void setDims(const SizeVector &a_dims);
66
67     /**
68     * @brief Sets the layout value for this Data instance
69     * @param layout Layout value to set
70     */
71     void setLayout(Layout layout);
72
73     /**
74      * @brief changes dims and layout at same time
75      * @param dims new dimensions
76      * @param layout new layout
77      */
78     void reshape(const SizeVector &dims, Layout layout);
79
80     /**
81     * @brief Gets the layout value for this Data instance
82     */
83     Layout getLayout() const;
84
85     /**
86     * @brief Gets Tensor descriptor reference
87       @return reference to TensorDesc
88     */
89     const TensorDesc& getTensorDesc() const;
90
91     /**
92      * @brief Gets a precision type of this Data instance
93      * @return Precision type
94      */
95     const Precision& getPrecision() const;
96
97     /**
98      * @brief Sets a precision type of this Data instance
99      * @param precision Precision of the data
100      */
101     void setPrecision(const Precision& precision);
102
103     /**
104      * @return data dimensions
105      */
106     const SizeVector& getDims() const;
107
108     /**
109      * @return owner of this data layer, parent layer in di-graph
110      */
111     CNNLayerWeakPtr& getCreatorLayer();
112
113     /**
114      * @return name of the data object
115      */
116     const std::string& getName() const;
117
118
119     /**
120      * @brief Sets a name the Data object
121      * @param newName Name of the data node
122      */
123
124     void setName(const std::string& newName);
125
126     /**
127      * @brief returns child layers in di-graph
128      */
129     std::map<std::string, CNNLayerPtr>& getInputTo();
130
131     /**
132      * @return convenient arbitrary user data holder
133      */
134     const UserValue& getUserObject() const;
135 private:
136     /**
137      * @brief A pointer to the layer that creates this data element, null for input data elements
138      */
139     CNNLayerWeakPtr creatorLayer;
140
141     /**
142      * @brief A unique name that identifies this data node
143      */
144     std::string name;
145
146     /**
147      * @brief A map of layers that use this node as input.
148      * It is useful for recursive NN graph traversal.
149      */
150     std::map<std::string, CNNLayerPtr> inputTo;
151
152     /**
153      * @brief A user utility place holder
154      */
155     UserValue userObject;
156
157     /**
158      * @brief A tensor descriptor
159      */
160     mutable TensorDesc tensorDesc;
161 };
162 }  // namespace InferenceEngine