ie_data.h
Go to the documentation of this file.
1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 /**
6  * @brief This header file defines the main Data representation node.
7  *
8  * @file ie_data.h
9  */
10 #pragma once
11 
12 #include <map>
13 #include <memory>
14 #include <string>
15 #include <vector>
16 
17 #include "ie_common.h"
18 #include "ie_layouts.h"
19 #include "ie_precision.hpp"
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 
28 class INFERENCE_ENGINE_API_CLASS(Data) {
29  class Impl;
30 public:
31  /**
32  * @brief An empty constructor (dimensionless)
33  *
34  * @param name Name of the data node
35  * @param _precision Precision of the data
36  * @param layout Data layout
37  */
38  Data(const std::string& name, Precision _precision, Layout layout = NCHW);
39 
40  /**
41  * @brief A constructor with tensor descriptor
42  *
43  * @param name Name of the data node
44  * @param desc Tensor descriptor
45  */
46  Data(const std::string& name, const TensorDesc& desc);
47 
48  /**
49  * @brief A copy constructor
50  *
51  * @param data A data object to copy from
52  */
53  Data(const Data& data);
54 
55  /**
56  * @brief An assignment operator
57  *
58  * @param data A data object to copy from
59  * @return An assigned object
60  */
61  Data & operator = (const Data& data);
62 
63  /**
64  * @brief Checks if the current node is resolved
65  *
66  * @return true if resolved, false otherwise.
67  */
68  bool isInitialized() const;
69 
70  /**
71  * @brief Sets the data dimensions.
72  *
73  * After the current node is marked as resolved.
74  *
75  * @param a_dims Tensor dimensions to set
76  */
77  void setDims(const SizeVector& a_dims);
78 
79  /**
80  * @brief Sets the layout value for this Data instance
81  *
82  * @param layout Layout value to set
83  */
84  void setLayout(Layout layout);
85 
86  /**
87  * @brief changes dims and layout at same time
88  *
89  * @param dims new dimensions
90  * @param layout new layout
91  */
92  void reshape(const SizeVector& dims, Layout layout);
93 
94  /**
95  * @brief Gets the layout value for this Data instance
96  */
97  Layout getLayout() const;
98 
99  /**
100  * @brief Gets Tensor descriptor reference
101  *
102  * @return reference to TensorDesc
103  */
104  const TensorDesc& getTensorDesc() const;
105 
106  /**
107  * @brief Gets a precision type of this Data instance
108  *
109  * @return Precision type
110  */
111  const Precision& getPrecision() const;
112 
113  /**
114  * @brief Sets a precision type of this Data instance
115  *
116  * @param precision Precision of the data
117  */
118  void setPrecision(const Precision& precision);
119 
120  /**
121  * @return data dimensions
122  */
123  const SizeVector& getDims() const;
124 
125  /**
126  * @return name of the data object
127  */
128  const std::string& getName() const;
129 
130  /**
131  * @brief Sets a name the Data object
132  *
133  * @param newName Name of the data node
134  */
135 
136  void setName(const std::string& newName);
137 
138  /**
139  * @return convenient arbitrary user data holder
140  */
141  const UserValue& getUserObject() const;
142 
143  /**
144  * @private
145  * @brief Don't touch this field. An implementation details for Data object.
146  */
147  std::shared_ptr<Impl> _impl;
148 
149 private:
150  /**
151  * @brief A unique name that identifies this data node
152  */
153  std::string name;
154 
155  /**
156  * @brief A user utility place holder
157  */
158  UserValue userObject;
159 
160  /**
161  * @brief A tensor descriptor
162  */
163  mutable TensorDesc tensorDesc;
164 };
165 } // namespace InferenceEngine
This class represents the main Data representation node.
Definition: ie_data.h:28
void setLayout(Layout layout)
Sets the layout value for this Data instance.
Layout getLayout() const
Gets the layout value for this Data instance.
void reshape(const SizeVector &dims, Layout layout)
changes dims and layout at same time
const std::string & getName() const
void setName(const std::string &newName)
Sets a name the Data object.
Data(const std::string &name, const TensorDesc &desc)
A constructor with tensor descriptor.
const Precision & getPrecision() const
Gets a precision type of this Data instance.
Data(const Data &data)
A copy constructor.
const UserValue & getUserObject() const
const TensorDesc & getTensorDesc() const
Gets Tensor descriptor reference.
void setPrecision(const Precision &precision)
Sets a precision type of this Data instance.
void setDims(const SizeVector &a_dims)
Sets the data dimensions.
Data(const std::string &name, Precision _precision, Layout layout=NCHW)
An empty constructor (dimensionless)
bool isInitialized() const
Checks if the current node is resolved.
const SizeVector & getDims() const
This class holds precision value and provides precision related operations.
Definition: ie_precision.hpp:23
This class defines Tensor description.
Definition: ie_layouts.h:158
This is a header file with common inference engine definitions.
A header file for data layouts and conversion between them.
A header file that provides class for describing precision of data.
Inference Engine C++ API.
Definition: cldnn_config.hpp:15
Layout
Layouts that the inference engine supports.
Definition: ie_common.h:63
@ NCHW
NCHW layout for input / output blobs.
Definition: ie_common.h:67
std::vector< size_t > SizeVector
Represents tensor size.
Definition: ie_common.h:27
The method holds the user values to enable binding of data per graph node.
Definition: ie_common.h:53