Compute Library
 23.08
Types.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2021, 2023 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"
36 
37 #include <limits>
38 #include <string>
39 
40 namespace arm_compute
41 {
42 namespace graph
43 {
47 
56 
70 
71 using GraphID = unsigned int;
72 using TensorID = unsigned int;
73 using NodeID = unsigned int;
74 using EdgeID = unsigned int;
76 
77 /**< Constant TensorID specifying an equivalent of null tensor */
78 constexpr TensorID NullTensorID = std::numeric_limits<TensorID>::max();
79 /**< Constant NodeID specifying an equivalent of null node */
80 constexpr NodeID EmptyNodeID = std::numeric_limits<NodeID>::max();
81 /**< Constant EdgeID specifying an equivalent of null edge */
82 constexpr EdgeID EmptyEdgeID = std::numeric_limits<EdgeID>::max();
83 
84 // Forward declarations
85 struct TensorDescriptor;
86 
87 /** Graph configuration structure */
89 {
90  bool use_function_memory_manager{ true }; /**< Use a memory manager to manage per-function auxilary memory */
91  bool use_function_weights_manager{ true }; /**< Use a weights manager to manage transformed weights */
92  bool use_transition_memory_manager{ true }; /**< Use a memory manager to manager transition buffer memory */
93  bool use_tuner{ false }; /**< Use a tuner in tunable backends */
94  bool use_synthetic_type{ false }; /**< Convert graph to a synthetic graph for a data type */
95  DataType synthetic_type{ DataType::QASYMM8 }; /**< The data type of the synthetic graph */
96  CLTunerMode tuner_mode{ CLTunerMode::EXHAUSTIVE }; /**< Tuner mode to be used by the CL tuner */
97  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. */
98  std::string tuner_file{ "acl_tuner.csv" }; /**< File to load/store tuning values from */
99  std::string mlgo_file{ "heuristics.mlgo" }; /**< Filename to load MLGO heuristics from */
100  CLBackendType backend_type{ CLBackendType::Native }; /**< CL backend type to use */
101 };
102 
103 /**< Device target types */
104 enum class Target
105 {
106  UNSPECIFIED, /**< Unspecified Target */
107  NEON, /**< Arm® Neon™ capable target device */
108  CL, /**< OpenCL capable target device */
109  CLVK, /**< CLVK capable target device */
110 };
111 
112 /** Supported Element-wise operations */
114 {
115  Add, /**< Arithmetic addition */
116  Sub, /**< Arithmetic subtraction */
117  Mul, /**< Arithmetic multiplication */
118  Max, /**< Arithmetic maximum */
119  Div, /**< Arithmetic division */
120  Min, /**< Arithmetic minimum */
121 };
122 
123 /** Supported Unary Element-wise operations */
125 {
126  Exp /**< Exp */
127 };
128 
129 /** Supported Convolution layer methods */
131 {
132  Default, /**< Default approach using internal heuristics */
133  GEMM, /**< GEMM based convolution */
134  Direct, /**< Deep direct convolution */
135  Winograd /**< Winograd based convolution */
136 };
137 
138 /** Supported Depthwise Convolution layer methods */
140 {
141  Default, /**< Default approach using internal heuristics */
142  GEMV, /**< Generic GEMV based depthwise convolution */
143  Optimized3x3, /**< Optimized 3x3 direct depthwise convolution */
144 };
145 
146 /** Enable or disable fast math for Convolution layer */
147 enum class FastMathHint
148 {
149  Enabled, /**< Fast math enabled for Convolution layer */
150  Disabled, /**< Fast math disabled for Convolution layer */
151 };
152 
153 /** Convolution post operator info */
155 {
156 public:
157  /** Returns post op type
158  *
159  * @return Post op type
160  */
161  virtual PostOpType type() const = 0;
162  virtual ~ConvPostOpInfo()
163  {
164  }
165 };
166 
168 {
169 public:
171  : _act(act)
172  {
173  }
175  {
176  }
177  PostOpType type() const override
178  {
179  return PostOpType::Activation;
180  }
182 };
183 
185 {
186 public:
187  ConvPostOpInfoEltwiseAdd(int arg_pos, const ConvertPolicy &policy)
188  : _prev_op_dst_pos(arg_pos), _policy(policy)
189  {
190  }
191  PostOpType type() const override
192  {
193  return PostOpType::Eltwise_Add;
194  }
196  {
197  }
200 };
201 
202 /** Supported nodes */
203 enum class NodeType
204 {
218  EltwiseLayer,
219  FlattenLayer,
229  PadLayer,
230  PermuteLayer,
231  PoolingLayer,
232  PReluLayer,
233  PrintLayer,
237  ReorgLayer,
238  ReshapeLayer,
239  ResizeLayer,
241  SoftmaxLayer,
242  SliceLayer,
243  SplitLayer,
244  StackLayer,
248 
249  Input,
250  Output,
251  Const,
252 
253  Dummy
254 };
255 
256 /** Backend Memory Manager affinity **/
258 {
259  Buffer, /**< Affinity at buffer level */
260  Offset /**< Affinity at offset level */
261 };
262 
263 /** NodeID-index struct
264  *
265  * Used to describe connections
266  */
268 {
269  NodeID node_id; /**< Node ID */
270  size_t index; /**< Index */
271 };
272 
273 /** Common node parameters */
275 {
276  std::string name; /**< Node name */
277  Target target; /**< Node target */
278 };
279 } // namespace graph
280 } // namespace arm_compute
281 #endif /* ARM_COMPUTE_GRAPH_TYPES_H */
arm_compute::graph::NodeParams
Common node parameters.
Definition: Types.h:274
arm_compute::graph::ConvolutionMethod::Default
@ Default
Default approach using internal heuristics.
arm_compute::graph::EltwiseOperation::Mul
@ Mul
Arithmetic multiplication.
arm_compute::graph::MemoryManagerAffinity::Offset
@ Offset
Affinity at offset level.
arm_compute::graph::NodeType::DepthToSpaceLayer
@ DepthToSpaceLayer
arm_compute::graph::GraphConfig::use_tuner
bool use_tuner
Use a tuner in tunable backends.
Definition: Types.h:93
arm_compute::graph::EmptyEdgeID
constexpr EdgeID EmptyEdgeID
Definition: Types.h:82
arm_compute::graph::NodeType::DetectionOutputLayer
@ DetectionOutputLayer
arm_compute::graph::GraphConfig::num_threads
int num_threads
Number of threads to use (thread capable backends), if 0 the backend will auto-initialize,...
Definition: Types.h:97
arm_compute::graph::GraphConfig::mlgo_file
std::string mlgo_file
Filename to load MLGO heuristics from.
Definition: Types.h:99
arm_compute::graph::NodeIdxPair::node_id
NodeID node_id
Node ID.
Definition: Types.h:269
arm_compute::graph::Target::CL
@ CL
OpenCL capable target device.
arm_compute::graph::NodeType::FlattenLayer
@ FlattenLayer
arm_compute::graph::ConvPostOpInfoEltwiseAdd::_prev_op_dst_pos
int _prev_op_dst_pos
Definition: Types.h:198
arm_compute::PixelValue
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:35
arm_compute::DataLayout
DataLayout
[DataLayout enum definition]
Definition: CoreTypes.h:109
arm_compute::graph::FastMathHint::Enabled
@ Enabled
Fast math enabled for Convolution layer.
arm_compute::graph::ConvolutionMethod::Direct
@ Direct
Deep direct convolution.
arm_compute::graph::NodeType::QuantizationLayer
@ QuantizationLayer
arm_compute::DataLayoutDimension
DataLayoutDimension
[DataLayout enum definition]
Definition: CoreTypes.h:120
arm_compute::DataType::QASYMM8
@ QASYMM8
quantized, asymmetric fixed-point 8-bit number unsigned
arm_compute::graph::NodeType::NormalizePlanarYUVLayer
@ NormalizePlanarYUVLayer
arm_compute::TensorShape
Shape of a tensor.
Definition: TensorShape.h:39
arm_compute::ActivationLayerInfo::ActivationFunction
arm_compute::ActivationFunction ActivationFunction
Definition: ActivationLayerInfo.h:58
arm_compute::graph::NodeType::DeconvolutionLayer
@ DeconvolutionLayer
ConvolutionInfo.h
ActivationLayerInfo.h
arm_compute::graph::NodeType::PriorBoxLayer
@ PriorBoxLayer
arm_compute::graph::ConvPostOpInfoEltwiseAdd::type
PostOpType type() const override
Returns post op type.
Definition: Types.h:191
arm_compute::graph::MemoryManagerAffinity::Buffer
@ Buffer
Affinity at buffer level.
arm_compute::graph::Target::NEON
@ NEON
Arm® Neon™ capable target device.
Types.h
arm_compute::graph::NodeType::UpsampleLayer
@ UpsampleLayer
arm_compute::graph::NodeType::ActivationLayer
@ ActivationLayer
arm_compute::Size2D
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34
arm_compute::InterpolationPolicy
InterpolationPolicy
Interpolation method.
Definition: Types.h:371
arm_compute::graph::NodeType::PoolingLayer
@ PoolingLayer
arm_compute::graph::GraphConfig::use_function_memory_manager
bool use_function_memory_manager
Use a memory manager to manage per-function auxilary memory.
Definition: Types.h:90
arm_compute::graph::NodeType::Dummy
@ Dummy
arm_compute::graph::NodeType::PermuteLayer
@ PermuteLayer
arm_compute::graph::NodeType::PadLayer
@ PadLayer
arm_compute::graph::NodeType::BoundingBoxTransformLayer
@ BoundingBoxTransformLayer
arm_compute::DimensionRoundingType
DimensionRoundingType
Dimension rounding type when down-scaling on CNNs.
Definition: CoreTypes.h:132
arm_compute::graph::Target::CLVK
@ CLVK
CLVK capable target device.
arm_compute::graph::NodeType::ROIAlignLayer
@ ROIAlignLayer
arm_compute::graph::NodeParams::name
std::string name
Node name.
Definition: Types.h:276
arm_compute::graph::NodeType::FusedDepthwiseConvolutionBatchNormalizationLayer
@ FusedDepthwiseConvolutionBatchNormalizationLayer
Error.h
arm_compute::graph::EltwiseOperation::Sub
@ Sub
Arithmetic subtraction.
arm_compute::graph::MemoryManagerAffinity
MemoryManagerAffinity
Backend Memory Manager affinity.
Definition: Types.h:257
arm_compute::graph::NodeIdxPair
NodeID-index struct.
Definition: Types.h:267
arm_compute::graph::UnaryEltwiseOperation::Exp
@ Exp
Exp.
arm_compute::CLTunerMode::EXHAUSTIVE
@ EXHAUSTIVE
Searches all possible LWS configurations while tuning.
arm_compute::graph::NodeType::NormalizationLayer
@ NormalizationLayer
arm_compute::graph::EltwiseOperation::Div
@ Div
Arithmetic division.
arm_compute::graph::GraphConfig::tuner_mode
CLTunerMode tuner_mode
Tuner mode to be used by the CL tuner.
Definition: Types.h:96
arm_compute::ActivationLayerInfo
Activation Layer Information class.
Definition: ActivationLayerInfo.h:55
arm_compute::graph::GraphConfig
Graph configuration structure.
Definition: Types.h:88
arm_compute::FullyConnectedLayerInfo
Fully connected layer info.
Definition: FullyConnectedLayerInfo.h:33
arm_compute::PermutationVector
Strides PermutationVector
Permutation vector.
Definition: CoreTypes.h:37
arm_compute::graph::Target
Target
Definition: Types.h:104
arm_compute::graph::ConvPostOpInfoActivation::~ConvPostOpInfoActivation
~ConvPostOpInfoActivation() override
Definition: Types.h:174
arm_compute::graph::NodeIdxPair::index
size_t index
Index.
Definition: Types.h:270
arm_compute::graph::NodeType::EltwiseLayer
@ EltwiseLayer
arm_compute::graph::NodeType::PReluLayer
@ PReluLayer
arm_compute::graph::NodeType::StridedSliceLayer
@ StridedSliceLayer
arm_compute::graph::ConvPostOpInfo
Convolution post operator info.
Definition: Types.h:154
arm_compute::graph::NodeType::DequantizationLayer
@ DequantizationLayer
arm_compute::graph::Target::UNSPECIFIED
@ UNSPECIFIED
Unspecified Target.
arm_compute::ActivationFunction
ActivationFunction
Available activation functions.
Definition: ActivationLayerInfo.h:35
arm_compute::PoolingLayerInfo
Pooling Layer Information struct.
Definition: Types.h:1018
arm_compute::graph::DepthwiseConvolutionMethod::GEMV
@ GEMV
Generic GEMV based depthwise convolution.
arm_compute::Status
Status class.
Definition: Error.h:52
arm_compute::graph::ConvPostOpInfo::~ConvPostOpInfo
virtual ~ConvPostOpInfo()
Definition: Types.h:162
arm_compute::graph::NodeType
NodeType
Supported nodes.
Definition: Types.h:203
arm_compute::graph::GraphConfig::use_function_weights_manager
bool use_function_weights_manager
Use a weights manager to manage transformed weights.
Definition: Types.h:91
arm_compute::DetectionOutputLayerInfo
Detection Output layer info.
Definition: Types.h:780
arm_compute::PoolingType
PoolingType
Available pooling types.
Definition: Types.h:491
arm_compute::graph::GraphID
unsigned int GraphID
Definition: Types.h:71
arm_compute::graph::NodeType::FullyConnectedLayer
@ FullyConnectedLayer
arm_compute::graph::FastMathHint::Disabled
@ Disabled
Fast math disabled for Convolution layer.
CLTypes.h
arm_compute::graph::ConvPostOpInfoActivation::ConvPostOpInfoActivation
ConvPostOpInfoActivation(const ActivationLayerInfo &act)
Definition: Types.h:170
arm_compute::graph::NodeType::ReshapeLayer
@ ReshapeLayer
arm_compute::graph::EltwiseOperation::Max
@ Max
Arithmetic maximum.
arm_compute::graph::NodeType::DetectionPostProcessLayer
@ DetectionPostProcessLayer
arm_compute::graph::NodeType::L2NormalizeLayer
@ L2NormalizeLayer
arm_compute::graph::ConvolutionMethod::GEMM
@ GEMM
GEMM based convolution.
arm_compute::graph::NodeType::SoftmaxLayer
@ SoftmaxLayer
arm_compute::graph::NodeType::SplitLayer
@ SplitLayer
arm_compute::graph::NodeType::UnaryEltwiseLayer
@ UnaryEltwiseLayer
arm_compute::PriorBoxLayerInfo
PriorBox layer info.
Definition: Types.h:643
PixelValue.h
arm_compute::Coordinates
Coordinates of an item.
Definition: Coordinates.h:37
arm_compute::graph::NodeType::Input
@ Input
arm_compute::graph::EltwiseOperation::Min
@ Min
Arithmetic minimum.
arm_compute::PadStrideInfo
Definition: CoreTypes.h:138
arm_compute::DetectionPostProcessLayerInfo
Detection Output layer info.
Definition: Types.h:899
CLTunerTypes.h
arm_compute::CLBackendType
CLBackendType
List the possible OpenCL backends.
Definition: CLTypes.h:55
FullyConnectedLayerInfo.h
arm_compute::graph::NodeType::ChannelShuffleLayer
@ ChannelShuffleLayer
arm_compute::graph::NodeID
unsigned int NodeID
Definition: Types.h:73
arm_compute::graph::ConvPostOpInfoActivation::type
PostOpType type() const override
Returns post op type.
Definition: Types.h:177
arm_compute::experimental::PostOpType::Activation
@ Activation
arm_compute::graph::ConvPostOpInfoEltwiseAdd::_policy
ConvertPolicy _policy
Definition: Types.h:199
arm_compute::graph::GraphConfig::backend_type
CLBackendType backend_type
CL backend type to use.
Definition: Types.h:100
arm_compute::graph::NodeType::ResizeLayer
@ ResizeLayer
arm_compute::graph::GraphConfig::synthetic_type
DataType synthetic_type
The data type of the synthetic graph
Definition: Types.h:95
arm_compute::experimental::PostOpType
PostOpType
Type of Post Op.
Definition: IPostOp.h:36
arm_compute::graph::FastMathHint
FastMathHint
Enable or disable fast math for Convolution layer.
Definition: Types.h:147
arm_compute::graph::NodeType::ConvolutionLayer
@ ConvolutionLayer
arm_compute::CLBackendType::Native
@ Native
OpenCL native backend.
arm_compute::graph::NodeType::ArgMinMaxLayer
@ ArgMinMaxLayer
arm_compute::graph::ConvolutionMethod
ConvolutionMethod
Supported Convolution layer methods.
Definition: Types.h:130
arm_compute::graph::EltwiseOperation::Add
@ Add
Arithmetic addition.
arm_compute::graph::ConvPostOpInfoEltwiseAdd::~ConvPostOpInfoEltwiseAdd
~ConvPostOpInfoEltwiseAdd() override
Definition: Types.h:195
arm_compute::NormalizationLayerInfo
Normalization Layer Information class.
Definition: Types.h:1475
arm_compute::graph::NodeType::Const
@ Const
arm_compute::graph::ConvPostOpInfoEltwiseAdd
Definition: Types.h:184
arm_compute
Copyright (c) 2017-2023 Arm Limited.
Definition: introduction.dox:24
arm_compute::graph::ConvPostOpInfoActivation
Definition: Types.h:167
arm_compute::graph::ConvPostOpInfo::type
virtual PostOpType type() const =0
Returns post op type.
arm_compute::ConvertPolicy
ConvertPolicy
Policy to handle integer overflow.
Definition: Types.h:364
arm_compute::graph::TensorDescriptor
Tensor metadata class.
Definition: TensorDescriptor.h:38
arm_compute::graph::ConvPostOpInfoEltwiseAdd::ConvPostOpInfoEltwiseAdd
ConvPostOpInfoEltwiseAdd(int arg_pos, const ConvertPolicy &policy)
Definition: Types.h:187
arm_compute::graph::GraphConfig::use_transition_memory_manager
bool use_transition_memory_manager
Use a memory manager to manager transition buffer memory.
Definition: Types.h:92
arm_compute::CLTunerMode
CLTunerMode
< OpenCL tuner modes
Definition: CLTunerTypes.h:35
arm_compute::graph::NodeType::PrintLayer
@ PrintLayer
arm_compute::graph::DepthwiseConvolutionMethod::Optimized3x3
@ Optimized3x3
Optimized 3x3 direct depthwise convolution.
arm_compute::graph::NullTensorID
constexpr TensorID NullTensorID
Constant NodeID specifying an equivalent of null node.
Definition: Types.h:78
arm_compute::graph::NodeType::FusedConvolutionBatchNormalizationLayer
@ FusedConvolutionBatchNormalizationLayer
arm_compute::graph::NodeType::Output
@ Output
arm_compute::graph::DepthwiseConvolutionMethod
DepthwiseConvolutionMethod
Supported Depthwise Convolution layer methods.
Definition: Types.h:139
arm_compute::graph::DepthwiseConvolutionMethod::Default
@ Default
Default approach using internal heuristics.
arm_compute::NormType
NormType
The normalization type used for the normalization layer.
Definition: Types.h:467
arm_compute::graph::NodeType::SliceLayer
@ SliceLayer
arm_compute::graph::EltwiseOperation
EltwiseOperation
Supported Element-wise operations.
Definition: Types.h:113
arm_compute::graph::ConvolutionMethod::Winograd
@ Winograd
Winograd based convolution.
arm_compute::graph::NodeType::BatchNormalizationLayer
@ BatchNormalizationLayer
arm_compute::graph::NodeType::ReorgLayer
@ ReorgLayer
GEMMInfo.h
arm_compute::graph::NodeType::FusedConvolutionBatchNormalizationLayerWithPostOpsLayer
@ FusedConvolutionBatchNormalizationLayerWithPostOpsLayer
arm_compute::graph::EmptyNodeID
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:80
arm_compute::graph::NodeType::ConcatenateLayer
@ ConcatenateLayer
arm_compute::graph::ConvPostOpInfoActivation::_act
ActivationLayerInfo _act
Definition: Types.h:181
arm_compute::DataType
DataType
Available data types.
Definition: CoreTypes.h:82
arm_compute::graph::NodeType::DepthwiseConvolutionLayer
@ DepthwiseConvolutionLayer
arm_compute::graph::TensorID
unsigned int TensorID
Definition: Types.h:72
arm_compute::graph::NodeType::ReductionOperationLayer
@ ReductionOperationLayer
arm_compute::graph::UnaryEltwiseOperation
UnaryEltwiseOperation
Supported Unary Element-wise operations.
Definition: Types.h:124
arm_compute::graph::NodeParams::target
Target target
Node target.
Definition: Types.h:277
arm_compute::graph::EdgeID
unsigned int EdgeID
Definition: Types.h:74
arm_compute::graph::NodeType::GenerateProposalsLayer
@ GenerateProposalsLayer
arm_compute::graph::GraphConfig::tuner_file
std::string tuner_file
File to load/store tuning values from.
Definition: Types.h:98
arm_compute::graph::NodeType::StackLayer
@ StackLayer
arm_compute::graph::NodeType::FusedConvolutionWithPostOp
@ FusedConvolutionWithPostOp
arm_compute::graph::GraphConfig::use_synthetic_type
bool use_synthetic_type
Convert graph to a synthetic graph for a data type.
Definition: Types.h:94