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