Compute Library
 21.08
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 
65 
66 using GraphID = unsigned int;
67 using TensorID = unsigned int;
68 using NodeID = unsigned int;
69 using EdgeID = unsigned int;
71 
72 /**< Constant TensorID specifying an equivalent of null tensor */
73 constexpr TensorID NullTensorID = std::numeric_limits<TensorID>::max();
74 /**< Constant NodeID specifying an equivalent of null node */
75 constexpr NodeID EmptyNodeID = std::numeric_limits<NodeID>::max();
76 /**< Constant EdgeID specifying an equivalent of null edge */
77 constexpr EdgeID EmptyEdgeID = std::numeric_limits<EdgeID>::max();
78 
79 // Forward declarations
80 struct TensorDescriptor;
81 
82 /** Graph configuration structure */
84 {
85  bool use_function_memory_manager{ true }; /**< Use a memory manager to manage per-function auxilary memory */
86  bool use_function_weights_manager{ true }; /**< Use a weights manager to manage transformed weights */
87  bool use_transition_memory_manager{ true }; /**< Use a memory manager to manager transition buffer memory */
88  bool use_tuner{ false }; /**< Use a tuner in tunable backends */
89  bool use_synthetic_type{ false }; /**< Convert graph to a synthetic graph for a data type */
90  DataType synthetic_type{ DataType::QASYMM8 }; /**< The data type of the synthetic graph */
91  CLTunerMode tuner_mode{ CLTunerMode::EXHAUSTIVE }; /**< Tuner mode to be used by the CL tuner */
92  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. */
93  std::string tuner_file{ "acl_tuner.csv" }; /**< File to load/store tuning values from */
94  std::string mlgo_file{ "heuristics.mlgo" }; /**< Filename to load MLGO heuristics from */
95  CLBackendType backend_type{ CLBackendType::Native }; /**< CL backend type to use */
96 };
97 
98 /**< Device target types */
99 enum class Target
100 {
101  UNSPECIFIED, /**< Unspecified Target */
102  NEON, /**< Arm® Neon™ capable target device */
103  CL, /**< OpenCL capable target device */
104  CLVK, /**< CLVK capable target device */
105 };
106 
107 /** Supported Element-wise operations */
109 {
110  Add, /**< Arithmetic addition */
111  Sub, /**< Arithmetic subtraction */
112  Mul, /**< Arithmetic multiplication */
113  Max, /**< Arithmetic maximum */
114  Div, /**< Arithmetic division */
115  Min, /**< Arithmetic minimum */
116 };
117 
118 /** Supported Unary Element-wise operations */
120 {
121  Exp /**< Exp */
122 };
123 
124 /** Supported Convolution layer methods */
126 {
127  Default, /**< Default approach using internal heuristics */
128  GEMM, /**< GEMM based convolution */
129  Direct, /**< Deep direct convolution */
130  Winograd /**< Winograd based convolution */
131 };
132 
133 /** Supported Depthwise Convolution layer methods */
135 {
136  Default, /**< Default approach using internal heuristics */
137  GEMV, /**< Generic GEMV based depthwise convolution */
138  Optimized3x3, /**< Optimized 3x3 direct depthwise convolution */
139 };
140 
141 /** Enable or disable fast math for Convolution layer */
142 enum class FastMathHint
143 {
144  Enabled, /**< Fast math enabled for Convolution layer */
145  Disabled, /**< Fast math disabled for Convolution layer */
146 };
147 
148 /** Supported nodes */
149 enum class NodeType
150 {
164  EltwiseLayer,
165  FlattenLayer,
173  PadLayer,
174  PermuteLayer,
175  PoolingLayer,
176  PReluLayer,
177  PrintLayer,
181  ReorgLayer,
182  ReshapeLayer,
183  ResizeLayer,
185  SoftmaxLayer,
186  SliceLayer,
187  SplitLayer,
188  StackLayer,
192 
193  Input,
194  Output,
195  Const,
196 
197  Dummy
198 };
199 
200 /** Backend Memory Manager affinity **/
202 {
203  Buffer, /**< Affinity at buffer level */
204  Offset /**< Affinity at offset level */
205 };
206 
207 /** NodeID-index struct
208  *
209  * Used to describe connections
210  */
212 {
213  NodeID node_id; /**< Node ID */
214  size_t index; /**< Index */
215 };
216 
217 /** Common node parameters */
219 {
220  std::string name; /**< Node name */
221  Target target; /**< Node target */
222 };
223 } // namespace graph
224 } // namespace arm_compute
225 #endif /* ARM_COMPUTE_GRAPH_TYPES_H */
Common node parameters.
Definition: Types.h:218
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:213
InterpolationPolicy
Interpolation method.
Definition: Types.h:389
Graph configuration structure Device target types.
Definition: Types.h:83
Shape of a tensor.
Definition: TensorShape.h:39
EltwiseOperation
Supported Element-wise operations.
Definition: Types.h:108
CLTunerMode tuner_mode
Tuner mode to be used by the CL tuner.
Definition: Types.h:91
bool use_function_weights_manager
Use a weights manager to manage transformed weights.
Definition: Types.h:86
DataLayoutDimension
[DataLayout enum definition]
Definition: Types.h:120
OpenCL native backend.
DimensionRoundingType
Dimension rounding type when down-scaling on CNNs.
Definition: Types.h:528
CLVK capable target device.
Normalization Layer Information class.
Definition: Types.h:1576
Strides PermutationVector
Permutation vector.
Definition: Types.h:49
Fully connected layer info.
Definition: Types.h:1538
Fast math enabled for Convolution layer.
Status class.
Definition: Error.h:52
Activation Layer Information class.
Definition: Types.h:1475
Target target
Node target.
Definition: Types.h:221
Copyright (c) 2017-2021 Arm Limited.
std::string mlgo_file
Filename to load MLGO heuristics from.
Definition: Types.h:94
ActivationFunction
Available activation functions.
Definition: Types.h:1479
std::string tuner_file
File to load/store tuning values from.
Definition: Types.h:93
Fast math disabled for Convolution layer.
bool use_transition_memory_manager
Use a memory manager to manager transition buffer memory.
Definition: Types.h:87
bool use_function_memory_manager
Use a memory manager to manage per-function auxilary memory.
Definition: Types.h:85
quantized, asymmetric fixed-point 8-bit number unsigned
DepthwiseConvolutionMethod
Supported Depthwise Convolution layer methods.
Definition: Types.h:134
Coordinates of an item.
Definition: Coordinates.h:37
Pooling Layer Information struct.
Definition: Types.h:1139
Generic GEMV based depthwise convolution.
PriorBox layer info.
Definition: Types.h:764
NodeType
Supported nodes.
Definition: Types.h:149
Padding and stride information class.
Definition: Types.h:647
constexpr EdgeID EmptyEdgeID
Definition: Types.h:77
NodeID-index struct.
Definition: Types.h:211
FastMathHint
Enable or disable fast math for Convolution layer.
Definition: Types.h:142
unsigned int EdgeID
Definition: Types.h:69
Detection Output layer info.
Definition: Types.h:901
PoolingType
Available pooling types.
Definition: Types.h:535
unsigned int NodeID
Definition: Types.h:68
CLBackendType
List the possible OpenCL backends.
Definition: CLTypes.h:63
bool use_synthetic_type
Convert graph to a synthetic graph for a data type.
Definition: Types.h:89
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:75
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:88
std::string name
Node name.
Definition: Types.h:220
ConvolutionMethod
Supported Convolution layer methods.
Definition: Types.h:125
Detection Output layer info.
Definition: Types.h:1020
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:92
Default approach using internal heuristics.
constexpr TensorID NullTensorID
Constant NodeID specifying an equivalent of null node.
Definition: Types.h:73
Optimized 3x3 direct depthwise convolution.
DataType
Available data types.
Definition: Types.h:77
unsigned int TensorID
Definition: Types.h:67
OpenCL capable target device.
Searches all possible LWS configurations while tuning.
CLBackendType backend_type
CL backend type to use.
Definition: Types.h:95
DataLayout
[DataLayout enum definition]
Definition: Types.h:111
NormType
The normalization type used for the normalization layer.
Definition: Types.h:502
DataType synthetic_type
The data type of the synthetic graph.
Definition: Types.h:90
MemoryManagerAffinity
Backend Memory Manager affinity.
Definition: Types.h:201
unsigned int GraphID
Definition: Types.h:66
UnaryEltwiseOperation
Supported Unary Element-wise operations.
Definition: Types.h:119