Compute Library
 21.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 
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 };
116 
117 /** Supported Unary Element-wise operations */
119 {
120  Exp /**< Exp */
121 };
122 
123 /** Supported Convolution layer methods */
125 {
126  Default, /**< Default approach using internal heuristics */
127  GEMM, /**< GEMM based convolution */
128  Direct, /**< Deep direct convolution */
129  Winograd /**< Winograd based convolution */
130 };
131 
132 /** Supported Depthwise Convolution layer methods */
134 {
135  Default, /**< Default approach using internal heuristics */
136  GEMV, /**< Generic GEMV based depthwise convolution */
137  Optimized3x3, /**< Optimized 3x3 direct depthwise convolution */
138 };
139 
140 /** Enable or disable fast math for Convolution layer */
141 enum class FastMathHint
142 {
143  Enabled, /**< Fast math enabled for Convolution layer */
144  Disabled, /**< Fast math disabled for Convolution layer */
145 };
146 
147 /** Supported nodes */
148 enum class NodeType
149 {
163  EltwiseLayer,
164  FlattenLayer,
172  PadLayer,
173  PermuteLayer,
174  PoolingLayer,
175  PReluLayer,
176  PrintLayer,
180  ReorgLayer,
181  ReshapeLayer,
182  ResizeLayer,
184  SoftmaxLayer,
185  SliceLayer,
186  SplitLayer,
187  StackLayer,
191 
192  Input,
193  Output,
194  Const,
195 
196  Dummy
197 };
198 
199 /** Backend Memory Manager affinity **/
201 {
202  Buffer, /**< Affinity at buffer level */
203  Offset /**< Affinity at offset level */
204 };
205 
206 /** NodeID-index struct
207  *
208  * Used to describe connections
209  */
211 {
212  NodeID node_id; /**< Node ID */
213  size_t index; /**< Index */
214 };
215 
216 /** Common node parameters */
218 {
219  std::string name; /**< Node name */
220  Target target; /**< Node target */
221 };
222 } // namespace graph
223 } // namespace arm_compute
224 #endif /* ARM_COMPUTE_GRAPH_TYPES_H */
Common node parameters.
Definition: Types.h:217
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:212
InterpolationPolicy
Interpolation method.
Definition: Types.h:392
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:123
DimensionRoundingType
Dimension rounding type when down-scaling on CNNs.
Definition: Types.h:531
CLVK capable target device.
Normalization Layer Information class.
Definition: Types.h:1575
Strides PermutationVector
Permutation vector.
Definition: Types.h:49
Fully connected layer info.
Definition: Types.h:1541
Fast math enabled for Convolution layer.
Status class.
Definition: Error.h:52
Activation Layer Information class.
Definition: Types.h:1478
Target target
Node target.
Definition: Types.h:220
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:1482
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:133
Coordinates of an item.
Definition: Coordinates.h:37
Pooling Layer Information struct.
Definition: Types.h:1142
Generic GEMV based depthwise convolution.
PriorBox layer info.
Definition: Types.h:767
NodeType
Supported nodes.
Definition: Types.h:148
Padding and stride information class.
Definition: Types.h:650
constexpr EdgeID EmptyEdgeID
Definition: Types.h:77
NodeID-index struct.
Definition: Types.h:210
FastMathHint
Enable or disable fast math for Convolution layer.
Definition: Types.h:141
unsigned int EdgeID
Definition: Types.h:69
Detection Output layer info.
Definition: Types.h:904
PoolingType
Available pooling types.
Definition: Types.h:538
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:219
ConvolutionMethod
Supported Convolution layer methods.
Definition: Types.h:124
Detection Output layer info.
Definition: Types.h:1023
int num_threads
Number of threads to use (thread capable backends), if 0 the backend will auto-initialize,...
Definition: Types.h:92
Default approach using internal heuristics.
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:114
NormType
The normalization type used for the normalization layer.
Definition: Types.h:505
DataType synthetic_type
The data type of the synthetic graph.
Definition: Types.h:90
MemoryManagerAffinity
Backend Memory Manager affinity.
Definition: Types.h:200
unsigned int GraphID
Definition: Types.h:66
UnaryEltwiseOperation
Supported Unary Element-wise operations.
Definition: Types.h:118