Compute Library
 21.02
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"
31 
32 #include <limits>
33 #include <string>
34 
35 namespace arm_compute
36 {
37 namespace graph
38 {
41 
50 
63 
64 using GraphID = unsigned int;
65 using TensorID = unsigned int;
66 using NodeID = unsigned int;
67 using EdgeID = unsigned int;
69 
70 /**< Constant TensorID specifying an equivalent of null tensor */
71 constexpr TensorID NullTensorID = std::numeric_limits<TensorID>::max();
72 /**< Constant NodeID specifying an equivalent of null node */
73 constexpr NodeID EmptyNodeID = std::numeric_limits<NodeID>::max();
74 /**< Constant EdgeID specifying an equivalent of null edge */
75 constexpr EdgeID EmptyEdgeID = std::numeric_limits<EdgeID>::max();
76 
77 // Forward declarations
78 struct TensorDescriptor;
79 /** Graph configuration structure */
81 {
82  bool use_function_memory_manager{ true }; /**< Use a memory manager to manage per-function auxilary memory */
83  bool use_function_weights_manager{ true }; /**< Use a weights manager to manage transformed weights */
84  bool use_transition_memory_manager{ true }; /**< Use a memory manager to manager transition buffer memory */
85  bool use_tuner{ false }; /**< Use a tuner in tunable backends */
86  bool convert_to_uint8{ false }; /**< Convert graph to a synthetic uint8 graph */
87  CLTunerMode tuner_mode{ CLTunerMode::EXHAUSTIVE }; /**< Tuner mode to be used by the CL tuner */
88  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. */
89  std::string tuner_file{ "acl_tuner.csv" }; /**< File to load/store tuning values from */
90  std::string mlgo_file{ "heuristics.mlgo" }; /**< Filename to load MLGO heuristics from */
91 };
92 
93 /**< Device target types */
94 enum class Target
95 {
96  UNSPECIFIED, /**< Unspecified Target */
97  NEON, /**< Neon capable target device */
98  CL, /**< OpenCL capable target device */
99  GC, /**< GLES compute capable target device */
100 };
101 
102 /** Supported Element-wise operations */
104 {
105  Add, /**< Arithmetic addition */
106  Sub, /**< Arithmetic subtraction */
107  Mul, /**< Arithmetic multiplication */
108  Max, /**< Arithmetic maximum */
109 };
110 
111 /** Supported Unary Element-wise operations */
113 {
114  Exp /**< Exp */
115 };
116 
117 /** Supported Convolution layer methods */
119 {
120  Default, /**< Default approach using internal heuristics */
121  GEMM, /**< GEMM based convolution */
122  Direct, /**< Deep direct convolution */
123  Winograd /**< Winograd based convolution */
124 };
125 
126 /** Supported Depthwise Convolution layer methods */
128 {
129  Default, /**< Default approach using internal heuristics */
130  GEMV, /**< Generic GEMV based depthwise convolution */
131  Optimized3x3, /**< Optimized 3x3 direct depthwise convolution */
132 };
133 
134 /** Enable or disable fast math for Convolution layer */
135 enum class FastMathHint
136 {
137  Enabled, /**< Fast math enabled for Convolution layer */
138  Disabled, /**< Fast math disabled for Convolution layer */
139 };
140 
141 /** Supported nodes */
142 enum class NodeType
143 {
157  EltwiseLayer,
158  FlattenLayer,
166  PadLayer,
167  PermuteLayer,
168  PoolingLayer,
169  PReluLayer,
170  PrintLayer,
174  ReorgLayer,
175  ReshapeLayer,
176  ResizeLayer,
178  SoftmaxLayer,
179  SliceLayer,
180  SplitLayer,
181  StackLayer,
185 
186  Input,
187  Output,
188  Const,
189 
190  Dummy
191 };
192 
193 /** Backend Memory Manager affinity **/
195 {
196  Buffer, /**< Affinity at buffer level */
197  Offset /**< Affinity at offset level */
198 };
199 
200 /** NodeID-index struct
201  *
202  * Used to describe connections
203  */
205 {
206  NodeID node_id; /**< Node ID */
207  size_t index; /**< Index */
208 };
209 
210 /** Common node parameters */
212 {
213  std::string name; /**< Node name */
214  Target target; /**< Node target */
215 };
216 } // namespace graph
217 } // namespace arm_compute
218 #endif /* ARM_COMPUTE_GRAPH_TYPES_H */
Common node parameters.
Definition: Types.h:211
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:206
InterpolationPolicy
Interpolation method.
Definition: Types.h:392
Graph configuration structure Device target types.
Definition: Types.h:80
Shape of a tensor.
Definition: TensorShape.h:39
EltwiseOperation
Supported Element-wise operations.
Definition: Types.h:103
CLTunerMode tuner_mode
Tuner mode to be used by the CL tuner.
Definition: Types.h:87
bool convert_to_uint8
Convert graph to a synthetic uint8 graph.
Definition: Types.h:86
bool use_function_weights_manager
Use a weights manager to manage transformed weights.
Definition: Types.h:83
DataLayoutDimension
[DataLayout enum definition]
Definition: Types.h:129
DimensionRoundingType
Dimension rounding type when down-scaling on CNNs.
Definition: Types.h:603
Normalization Layer Information class.
Definition: Types.h:1647
Strides PermutationVector
Permutation vector.
Definition: Types.h:49
Fully connected layer info.
Definition: Types.h:1613
Fast math enabled for Convolution layer.
Status class.
Definition: Error.h:52
Activation Layer Information class.
Definition: Types.h:1550
Target target
Node target.
Definition: Types.h:214
Copyright (c) 2017-2021 Arm Limited.
std::string mlgo_file
Filename to load MLGO heuristics from.
Definition: Types.h:90
ActivationFunction
Available activation functions.
Definition: Types.h:1554
std::string tuner_file
File to load/store tuning values from.
Definition: Types.h:89
Fast math disabled for Convolution layer.
GLES compute capable target device.
bool use_transition_memory_manager
Use a memory manager to manager transition buffer memory.
Definition: Types.h:84
bool use_function_memory_manager
Use a memory manager to manage per-function auxilary memory.
Definition: Types.h:82
DepthwiseConvolutionMethod
Supported Depthwise Convolution layer methods.
Definition: Types.h:127
Coordinates of an item.
Definition: Coordinates.h:37
Pooling Layer Information struct.
Definition: Types.h:1214
Generic GEMV based depthwise convolution.
PriorBox layer info.
Definition: Types.h:839
NodeType
Supported nodes.
Definition: Types.h:142
Padding and stride information class.
Definition: Types.h:722
constexpr EdgeID EmptyEdgeID
Definition: Types.h:75
NodeID-index struct.
Definition: Types.h:204
FastMathHint
Enable or disable fast math for Convolution layer.
Definition: Types.h:135
unsigned int EdgeID
Definition: Types.h:67
Detection Output layer info.
Definition: Types.h:976
PoolingType
Available pooling types.
Definition: Types.h:610
unsigned int NodeID
Definition: Types.h:66
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:73
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:85
std::string name
Node name.
Definition: Types.h:213
ConvolutionMethod
Supported Convolution layer methods.
Definition: Types.h:118
Detection Output layer info.
Definition: Types.h:1095
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:88
Default approach using internal heuristics.
constexpr TensorID NullTensorID
Constant NodeID specifying an equivalent of null node.
Definition: Types.h:71
Optimized 3x3 direct depthwise convolution.
DataType
Available data types.
Definition: Types.h:77
unsigned int TensorID
Definition: Types.h:65
OpenCL capable target device.
Searches all possible LWS configurations while tuning.
DataLayout
[DataLayout enum definition]
Definition: Types.h:120
NormType
The normalization type used for the normalization layer.
Definition: Types.h:569
MemoryManagerAffinity
Backend Memory Manager affinity.
Definition: Types.h:194
unsigned int GraphID
Definition: Types.h:64
UnaryEltwiseOperation
Supported Unary Element-wise operations.
Definition: Types.h:112