ie_data.h
Go to the documentation of this file.
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  * @deprecated Deprecated. Please use getPrecision()
31  * @brief A precision type of this Data instance
32  */
34  /**
35  * @deprecated Deprecated. Please use getFormat()
36  * @brief A data layout of this Data instance
37  */
39  /**
40  * @deprecated Deprecated. Please use getDims()
41  * @brief A tensor dimension array (the order is opposite to the order in the IR: w,h,c,n) of this Data instance
42  */
44  /**
45  * @deprecated Deprecated. Please use getCreatorLayer()
46  * @brief A pointer to the layer that creates this data element, null for input data elements
47  */
49  /**
50  * @deprecated Deprecated. Please use getName()
51  * @brief A unique name that identifies this data node
52  */
53  std::string name;
54  /**
55  * @deprecated Deprecated. Please use getInputTo()
56  * @brief A map of layers that use this node as input.
57  * It is useful for recursive NN graph traversal.
58  */
59  std::map<std::string, CNNLayerPtr> inputTo;
60  /**
61  * @deprecated Deprecated. Please use getUserObject()
62  * @brief A user utility place holder
63  */
65 
66  /**
67  * @brief An empty constructor (dimensionless)
68  * @param name Name of the data node
69  * @param _precision Precision of the data
70  */
71  Data(const std::string &name, Precision _precision, Layout layout = NCHW);
72 
73  /**
74  * @brief A full constructor (with dimensions)
75  * @param name Name of the data node
76  * @param a_dims Data tensor dimensions
77  * @param _precision Precision of the data
78  */
79  Data(const std::string &name, const SizeVector &a_dims, Precision _precision, Layout layout = NCHW);
80  /**
81  * @brief A constructor with tensor descriptor
82  * @param name Name of the data node
83  * @param desc Tensor descriptor
84  */
85  Data(const std::string &name, const TensorDesc& desc);
86 
87  /**
88  * @brief Checks if the current node is resolved
89  * @return true if resolved, false otherwise.
90  */
91  bool isInitialized() const;
92 
93  /**
94  * @brief Sets the data dimensions.
95  * After the current node is marked as resolved.
96  * @param a_dims Tensor dimensions to set
97  */
98  void setDims(const SizeVector &a_dims);
99 
100  /**
101  * @deprecated
102  * @brief Sets the batch value in the data dimensions.
103  * Batch is defined as the last element in the dimensions vector.
104  * @param batch_size Batch size to set
105  */
106  void setBatchSize(size_t batch_size);
107 
108  /**
109  * @brief Sets the layout value for this Data instance
110  * @param layout Layout value to set
111  */
112  void setLayout(Layout layout);
113 
114  /**
115  * @brief changes dims and layout at same time
116  * @param dims new dimensions
117  * @param layout new layout
118  */
119  void reshape(const SizeVector &dims, Layout layout);
120 
121  /**
122  * @brief Gets the layout value for this Data instance
123  */
124  Layout getLayout() const;
125 
126  /**
127  * @brief Gets Tensor descriptor reference
128  @return reference to TensorDesc
129  */
130  const TensorDesc& getTensorDesc() const;
131 
132  /**
133  * @brief Gets a precision type of this Data instance
134  * @return Precision type
135  */
136  const Precision& getPrecision() const;
137 
138  /**
139  * @brief Gets a precision type of this Data instance
140  * @return Precision type
141  */
142  void setPrecision(const Precision& precision);
143 
144  /**
145  * @return data dimensions
146  */
147  const SizeVector& getDims() const;
148 
149  /**
150  * @return owner of this data layer, parent layer in di-graph
151  */
152  CNNLayerWeakPtr& getCreatorLayer();
153 
154  /**
155  * @return name of the data object
156  */
157  const std::string& getName() const;
158 
159  /**
160  * @brief returns child layers in di-graph
161  */
162  std::map<std::string, CNNLayerPtr>& getInputTo();
163 
164  /**
165  * @return convenient arbitrary user data holder
166  */
167  const UserValue& getUserObject() const;
168 private:
169  mutable TensorDesc tensorDesc;
170 };
171 } // namespace InferenceEngine
The method holds the user values to enable binding of data per graph node.
Definition: ie_common.h:66
UserValue userObject
A user utility place holder.
Definition: ie_data.h:64
std::vector< size_t > SizeVector
Represents tensor size. The order is opposite to the order in Caffe*: (w,h,n,b) where the most freque...
Definition: ie_common.h:26
Definition: ie_argmax_layer.hpp:11
Layout
Layouts that the inference engine supports.
Definition: ie_common.h:76
std::map< std::string, CNNLayerPtr > inputTo
A map of layers that use this node as input. It is useful for recursive NN graph traversal.
Definition: ie_data.h:59
std::weak_ptr< CNNLayer > CNNLayerWeakPtr
A smart weak pointer to the CNNLayer.
Definition: ie_common.h:40
This class defines Tensor description.
Definition: ie_layouts.h:143
CNNLayerWeakPtr creatorLayer
A pointer to the layer that creates this data element, null for input data elements.
Definition: ie_data.h:48
A header file that provides class for describing precision of data.
A header file for data layouts and conversion between them.
Precision precision
A precision type of this Data instance.
Definition: ie_data.h:33
Layout layout
A data layout of this Data instance.
Definition: ie_data.h:38
std::string name
A unique name that identifies this data node.
Definition: ie_data.h:53
The macro defines a symbol import/export mechanism essential for Microsoft Windows(R) OS...
This class represents the main Data representation node.
Definition: ie_data.h:27
This is a header file with common inference engine definitions.
A header file for the main Inference Engine exception.
This class holds precision value and provides precision related operations.
Definition: ie_precision.hpp:19
SizeVector dims
A tensor dimension array (the order is opposite to the order in the IR: w,h,c,n) of this Data instanc...
Definition: ie_data.h:43