Compute Library
 22.05
Types.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2021 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef ARM_COMPUTE_GRAPH_TYPES_H
25 #define ARM_COMPUTE_GRAPH_TYPES_H
26 
27 #include "arm_compute/core/Error.h"
29 #include "arm_compute/core/Types.h"
32 
33 #include <limits>
34 #include <string>
35 
36 namespace arm_compute
37 {
38 namespace graph
39 {
43 
52 
66 
67 using GraphID = unsigned int;
68 using TensorID = unsigned int;
69 using NodeID = unsigned int;
70 using EdgeID = unsigned int;
72 
73 /**< Constant TensorID specifying an equivalent of null tensor */
74 constexpr TensorID NullTensorID = std::numeric_limits<TensorID>::max();
75 /**< Constant NodeID specifying an equivalent of null node */
76 constexpr NodeID EmptyNodeID = std::numeric_limits<NodeID>::max();
77 /**< Constant EdgeID specifying an equivalent of null edge */
78 constexpr EdgeID EmptyEdgeID = std::numeric_limits<EdgeID>::max();
79 
80 // Forward declarations
81 struct TensorDescriptor;
82 
83 /** Graph configuration structure */
85 {
86  bool use_function_memory_manager{ true }; /**< Use a memory manager to manage per-function auxilary memory */
87  bool use_function_weights_manager{ true }; /**< Use a weights manager to manage transformed weights */
88  bool use_transition_memory_manager{ true }; /**< Use a memory manager to manager transition buffer memory */
89  bool use_tuner{ false }; /**< Use a tuner in tunable backends */
90  bool use_synthetic_type{ false }; /**< Convert graph to a synthetic graph for a data type */
91  DataType synthetic_type{ DataType::QASYMM8 }; /**< The data type of the synthetic graph */
92  CLTunerMode tuner_mode{ CLTunerMode::EXHAUSTIVE }; /**< Tuner mode to be used by the CL tuner */
93  int num_threads{ -1 }; /**< Number of threads to use (thread capable backends), if 0 the backend will auto-initialize, if -1 the backend will stay as it is. */
94  std::string tuner_file{ "acl_tuner.csv" }; /**< File to load/store tuning values from */
95  std::string mlgo_file{ "heuristics.mlgo" }; /**< Filename to load MLGO heuristics from */
96  CLBackendType backend_type{ CLBackendType::Native }; /**< CL backend type to use */
97 };
98 
99 /**< Device target types */
100 enum class Target
101 {
102  UNSPECIFIED, /**< Unspecified Target */
103  NEON, /**< Arm® Neon™ capable target device */
104  CL, /**< OpenCL capable target device */
105  CLVK, /**< CLVK capable target device */
106 };
107 
108 /** Supported Element-wise operations */
110 {
111  Add, /**< Arithmetic addition */
112  Sub, /**< Arithmetic subtraction */
113  Mul, /**< Arithmetic multiplication */
114  Max, /**< Arithmetic maximum */
115  Div, /**< Arithmetic division */
116  Min, /**< Arithmetic minimum */
117 };
118 
119 /** Supported Unary Element-wise operations */
121 {
122  Exp /**< Exp */
123 };
124 
125 /** Supported Convolution layer methods */
127 {
128  Default, /**< Default approach using internal heuristics */
129  GEMM, /**< GEMM based convolution */
130  Direct, /**< Deep direct convolution */
131  Winograd /**< Winograd based convolution */
132 };
133 
134 /** Supported Depthwise Convolution layer methods */
136 {
137  Default, /**< Default approach using internal heuristics */
138  GEMV, /**< Generic GEMV based depthwise convolution */
139  Optimized3x3, /**< Optimized 3x3 direct depthwise convolution */
140 };
141 
142 /** Enable or disable fast math for Convolution layer */
143 enum class FastMathHint
144 {
145  Enabled, /**< Fast math enabled for Convolution layer */
146  Disabled, /**< Fast math disabled for Convolution layer */
147 };
148 
149 /** Convolution post operator info */
151 {
152 public:
153  /** Returns post op type
154  *
155  * @return Post op type
156  */
157  virtual PostOpType type() const = 0;
158  virtual ~ConvPostOpInfo()
159  {
160  }
161 };
162 
164 {
165 public:
167  : _act(act)
168  {
169  }
171  {
172  }
173  PostOpType type() const override
174  {
175  return PostOpType::Activation;
176  }
178 };
179 
181 {
182 public:
183  ConvPostOpInfoEltwiseAdd(int arg_pos, const ConvertPolicy &policy)
184  : _prev_op_dst_pos(arg_pos), _policy(policy)
185  {
186  }
187  PostOpType type() const override
188  {
189  return PostOpType::Eltwise_Add;
190  }
192  {
193  }
196 };
197 
198 /** Supported nodes */
199 enum class NodeType
200 {
214  EltwiseLayer,
215  FlattenLayer,
225  PadLayer,
226  PermuteLayer,
227  PoolingLayer,
228  PReluLayer,
229  PrintLayer,
233  ReorgLayer,
234  ReshapeLayer,
235  ResizeLayer,
237  SoftmaxLayer,
238  SliceLayer,
239  SplitLayer,
240  StackLayer,
244 
245  Input,
246  Output,
247  Const,
248 
249  Dummy
250 };
251 
252 /** Backend Memory Manager affinity **/
254 {
255  Buffer, /**< Affinity at buffer level */
256  Offset /**< Affinity at offset level */
257 };
258 
259 /** NodeID-index struct
260  *
261  * Used to describe connections
262  */
264 {
265  NodeID node_id; /**< Node ID */
266  size_t index; /**< Index */
267 };
268 
269 /** Common node parameters */
271 {
272  std::string name; /**< Node name */
273  Target target; /**< Node target */
274 };
275 } // namespace graph
276 } // namespace arm_compute
277 #endif /* ARM_COMPUTE_GRAPH_TYPES_H */
Common node parameters.
Definition: Types.h:270
Arm® Neon™ capable target device.
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:34
NodeID node_id
Node ID.
Definition: Types.h:265
InterpolationPolicy
Interpolation method.
Definition: Types.h:411
Graph configuration structure Device target types.
Definition: Types.h:84
Shape of a tensor.
Definition: TensorShape.h:39
EltwiseOperation
Supported Element-wise operations.
Definition: Types.h:109
CLTunerMode tuner_mode
Tuner mode to be used by the CL tuner.
Definition: Types.h:92
bool use_function_weights_manager
Use a weights manager to manage transformed weights.
Definition: Types.h:87
DataLayoutDimension
[DataLayout enum definition]
Definition: Types.h:124
PostOpType
Type of Post Op.
Definition: IPostOp.h:36
PostOpType type() const override
Returns post op type.
Definition: Types.h:187
OpenCL native backend.
int _prev_op_dst_pos
Definition: Types.h:194
~ConvPostOpInfoEltwiseAdd() override
Definition: Types.h:191
DimensionRoundingType
Dimension rounding type when down-scaling on CNNs.
Definition: Types.h:550
CLVK capable target device.
Normalization Layer Information class.
Definition: Types.h:1726
Strides PermutationVector
Permutation vector.
Definition: Types.h:51
Fully connected layer info.
Definition: Types.h:1688
Fast math enabled for Convolution layer.
ConvertPolicy _policy
Definition: Types.h:195
ConvPostOpInfoEltwiseAdd(int arg_pos, const ConvertPolicy &policy)
Definition: Types.h:183
Status class.
Definition: Error.h:52
Activation Layer Information class.
Definition: Types.h:1625
decltype(strategy::transforms) typedef type
Target target
Node target.
Definition: Types.h:273
Copyright (c) 2017-2022 Arm Limited.
std::string mlgo_file
Filename to load MLGO heuristics from.
Definition: Types.h:95
ActivationFunction
Available activation functions.
Definition: Types.h:1629
std::string tuner_file
File to load/store tuning values from.
Definition: Types.h:94
Fast math disabled for Convolution layer.
Definition: Types.h:163
bool use_transition_memory_manager
Use a memory manager to manager transition buffer memory.
Definition: Types.h:88
bool use_function_memory_manager
Use a memory manager to manage per-function auxilary memory.
Definition: Types.h:86
quantized, asymmetric fixed-point 8-bit number unsigned
DepthwiseConvolutionMethod
Supported Depthwise Convolution layer methods.
Definition: Types.h:135
Coordinates of an item.
Definition: Coordinates.h:37
Pooling Layer Information struct.
Definition: Types.h:1186
Generic GEMV based depthwise convolution.
PriorBox layer info.
Definition: Types.h:811
NodeType
Supported nodes.
Definition: Types.h:199
Padding and stride information class.
Definition: Types.h:669
PostOpType type() const override
Returns post op type.
Definition: Types.h:173
constexpr EdgeID EmptyEdgeID
Definition: Types.h:78
ActivationLayerInfo _act
Definition: Types.h:177
NodeID-index struct.
Definition: Types.h:263
FastMathHint
Enable or disable fast math for Convolution layer.
Definition: Types.h:143
unsigned int EdgeID
Definition: Types.h:70
Detection Output layer info.
Definition: Types.h:948
PoolingType
Available pooling types.
Definition: Types.h:557
unsigned int NodeID
Definition: Types.h:69
virtual ~ConvPostOpInfo()
Definition: Types.h:158
CLBackendType
List the possible OpenCL backends.
Definition: CLTypes.h:53
ConvPostOpInfoActivation(const ActivationLayerInfo &act)
Definition: Types.h:166
Convolution post operator info.
Definition: Types.h:150
bool use_synthetic_type
Convert graph to a synthetic graph for a data type.
Definition: Types.h:90
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:76
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34
CLTunerMode
< OpenCL tuner modes
Definition: CLTunerTypes.h:35
bool use_tuner
Use a tuner in tunable backends.
Definition: Types.h:89
std::string name
Node name.
Definition: Types.h:272
ConvolutionMethod
Supported Convolution layer methods.
Definition: Types.h:126
Detection Output layer info.
Definition: Types.h:1067
int num_threads
Number of threads to use (thread capable backends), if 0 the backend will auto-initialize, if -1 the backend will stay as it is.
Definition: Types.h:93
Default approach using internal heuristics.
~ConvPostOpInfoActivation() override
Definition: Types.h:170
constexpr TensorID NullTensorID
Constant NodeID specifying an equivalent of null node.
Definition: Types.h:74
Optimized 3x3 direct depthwise convolution.
DataType
Available data types.
Definition: Types.h:79
unsigned int TensorID
Definition: Types.h:68
Definition: Types.h:180
OpenCL capable target device.
Searches all possible LWS configurations while tuning.
CLBackendType backend_type
CL backend type to use.
Definition: Types.h:96
DataLayout
[DataLayout enum definition]
Definition: Types.h:113
NormType
The normalization type used for the normalization layer.
Definition: Types.h:524
DataType synthetic_type
The data type of the synthetic graph.
Definition: Types.h:91
ConvertPolicy
Policy to handle integer overflow.
Definition: Types.h:404
MemoryManagerAffinity
Backend Memory Manager affinity.
Definition: Types.h:253
unsigned int GraphID
Definition: Types.h:67
UnaryEltwiseOperation
Supported Unary Element-wise operations.
Definition: Types.h:120