blob: 82015114ba2faab648b313ce4c05f91d788c368a [file] [log] [blame]
Anthony Barbier2a07e182017-08-04 18:20:27 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2018-2020 Arm Limited.
Anthony Barbier2a07e182017-08-04 18:20:27 +01003 *
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 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_GRAPH_TYPES_H
25#define ARM_COMPUTE_GRAPH_TYPES_H
Anthony Barbier2a07e182017-08-04 18:20:27 +010026
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010027#include "arm_compute/core/Error.h"
Georgios Pinitas102b0ce2020-02-13 17:59:09 +000028#include "arm_compute/core/PixelValue.h"
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010029#include "arm_compute/core/Types.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010030#include "arm_compute/runtime/CL/CLTunerTypes.h"
Georgios Pinitas7d3d1b92017-10-12 17:34:20 +010031
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010032#include <limits>
33#include <string>
Anthony Barbier2a07e182017-08-04 18:20:27 +010034
35namespace arm_compute
36{
37namespace graph
38{
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010039using arm_compute::CLTunerMode;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010040using arm_compute::Status;
41
Georgios Pinitase2c82fe2017-10-02 18:51:47 +010042using arm_compute::Coordinates;
43using arm_compute::DataType;
Georgios Pinitascac13b12018-04-27 19:07:19 +010044using arm_compute::DataLayout;
45using arm_compute::DataLayoutDimension;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010046using arm_compute::TensorShape;
47using arm_compute::Size2D;
Georgios Pinitas57c48242018-08-02 13:41:49 +010048using arm_compute::PermutationVector;
Georgios Pinitas102b0ce2020-02-13 17:59:09 +000049using arm_compute::PixelValue;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010050
51using arm_compute::ActivationLayerInfo;
Isabella Gottardi7234ed82018-11-27 08:51:10 +000052using arm_compute::DetectionOutputLayerInfo;
Isabella Gottardia7acb3c2019-01-08 13:48:44 +000053using arm_compute::DetectionPostProcessLayerInfo;
Georgios Pinitas6f669f02017-09-26 12:32:57 +010054using arm_compute::NormType;
55using arm_compute::NormalizationLayerInfo;
Georgios Pinitasc55cef12018-08-01 15:24:18 +010056using arm_compute::FullyConnectedLayerInfo;
Georgios Pinitase2c82fe2017-10-02 18:51:47 +010057using arm_compute::PadStrideInfo;
Anthony Barbier2a07e182017-08-04 18:20:27 +010058using arm_compute::PoolingLayerInfo;
59using arm_compute::PoolingType;
Pablo Tello32521432018-11-15 14:43:10 +000060using arm_compute::PriorBoxLayerInfo;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010061using arm_compute::DimensionRoundingType;
Georgios Pinitas087eaf62018-05-16 15:52:35 +010062using arm_compute::InterpolationPolicy;
Anthony Barbier2a07e182017-08-04 18:20:27 +010063
Georgios Pinitas54c92fd2018-11-05 12:16:15 +000064using GraphID = unsigned int;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010065using TensorID = unsigned int;
66using NodeID = unsigned int;
67using EdgeID = unsigned int;
68using Activation = arm_compute::ActivationLayerInfo::ActivationFunction;
Georgios Pinitas7d3d1b92017-10-12 17:34:20 +010069
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010070/**< Constant TensorID specifying an equivalent of null tensor */
71constexpr TensorID NullTensorID = std::numeric_limits<TensorID>::max();
72/**< Constant NodeID specifying an equivalent of null node */
73constexpr NodeID EmptyNodeID = std::numeric_limits<NodeID>::max();
74/**< Constant EdgeID specifying an equivalent of null edge */
75constexpr EdgeID EmptyEdgeID = std::numeric_limits<EdgeID>::max();
76
77// Forward declarations
Georgios Pinitas879d1312019-09-30 13:25:53 +010078struct TensorDescriptor;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010079/** Graph configuration structure */
80struct GraphConfig
Anthony Barbier2a07e182017-08-04 18:20:27 +010081{
Aleksandr Nikolaeva084b462020-06-25 12:25:52 +010082 bool use_function_memory_manager{ true }; /**< Use a memory manager to manage per-function auxilary memory */
Michalis Spyrou1a569a32019-09-10 17:20:34 +010083 bool use_function_weights_manager{ true }; /**< Use a weights manager to manage transformed weights */
Anthony Barbier7b607dc2018-07-13 15:55:24 +010084 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 */
Georgios Pinitasf4261ad2019-12-02 11:58:19 +000086 bool convert_to_uint8{ false }; /**< Convert graph to a synthetic uint8 graph */
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010087 CLTunerMode tuner_mode{ CLTunerMode::EXHAUSTIVE }; /**< Tuner mode to be used by the CL tuner */
Anthony Barbier7b607dc2018-07-13 15:55:24 +010088 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 */
Anthony Barbier2a07e182017-08-04 18:20:27 +010090};
91
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010092/**< Device target types */
93enum class Target
94{
95 UNSPECIFIED, /**< Unspecified Target */
96 NEON, /**< NEON capable target device */
97 CL, /**< OpenCL capable target device */
98 GC, /**< GLES compute capable target device */
99};
100
101/** Supported Element-wise operations */
102enum class EltwiseOperation
103{
Georgios Pinitase2220552018-07-20 13:23:44 +0100104 Add, /**< Arithmetic addition */
105 Sub, /**< Arithmetic subtraction */
Sheri Zhang16dddd22020-05-27 15:03:48 +0100106 Mul, /**< Arithmetic multiplication */
thecha01f8e35842020-07-28 17:28:17 +0100107 Max, /**< Arithmetic maximum */
Sheri Zhang16dddd22020-05-27 15:03:48 +0100108};
109
110/** Supported Unary Element-wise operations */
111enum class UnaryEltwiseOperation
112{
113 Exp /**< Exp */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100114};
115
116/** Supported Convolution layer methods */
117enum class ConvolutionMethod
118{
Georgios Pinitase2220552018-07-20 13:23:44 +0100119 Default, /**< Default approach using internal heuristics */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100120 GEMM, /**< GEMM based convolution */
Georgios Pinitase2220552018-07-20 13:23:44 +0100121 Direct, /**< Deep direct convolution */
122 Winograd /**< Winograd based convolution */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100123};
124
125/** Supported Depthwise Convolution layer methods */
126enum class DepthwiseConvolutionMethod
127{
Georgios Pinitase2220552018-07-20 13:23:44 +0100128 Default, /**< Default approach using internal heuristics */
129 GEMV, /**< Generic GEMV based depthwise convolution */
130 Optimized3x3, /**< Optimized 3x3 direct depthwise convolution */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100131};
132
Giorgio Arena59631a12018-05-02 13:59:04 +0100133/** Enable or disable fast math for Convolution layer */
134enum class FastMathHint
135{
Georgios Pinitase2220552018-07-20 13:23:44 +0100136 Enabled, /**< Fast math enabled for Convolution layer */
137 Disabled, /**< Fast math disabled for Convolution layer */
Giorgio Arena59631a12018-05-02 13:59:04 +0100138};
139
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100140/** Supported nodes */
141enum class NodeType
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100142{
143 ActivationLayer,
144 BatchNormalizationLayer,
Manuel Bottinid2048ce2018-10-23 17:00:42 +0100145 BoundingBoxTransformLayer,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100146 ChannelShuffleLayer,
Georgios Pinitase2220552018-07-20 13:23:44 +0100147 ConcatenateLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100148 ConvolutionLayer,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100149 DeconvolutionLayer,
thecha010a05e6a2020-08-28 18:40:38 +0100150 DepthToSpaceLayer,
Michalis Spyrou7bfe4c52017-11-24 09:54:20 +0000151 DepthwiseConvolutionLayer,
Isabella Gottardicd4e9ab2019-11-05 17:50:27 +0000152 DequantizationLayer,
Isabella Gottardi7234ed82018-11-27 08:51:10 +0000153 DetectionOutputLayer,
Isabella Gottardia7acb3c2019-01-08 13:48:44 +0000154 DetectionPostProcessLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100155 EltwiseLayer,
Michalis Spyrou27c9efb2017-10-09 15:46:30 +0100156 FlattenLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100157 FullyConnectedLayer,
giuros01acce5042019-02-21 17:32:34 +0000158 FusedConvolutionBatchNormalizationLayer,
Manuel Bottinibffb41e2019-06-20 16:00:27 +0100159 FusedDepthwiseConvolutionBatchNormalizationLayer,
Manuel Bottini5209be52019-02-13 16:34:56 +0000160 GenerateProposalsLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100161 NormalizationLayer,
Michele Di Giorgio555d1102018-09-12 13:51:59 +0100162 NormalizePlanarYUVLayer,
Michele Di Giorgio4bb17332018-09-26 13:56:51 +0100163 PadLayer,
Georgios Pinitas57c48242018-08-02 13:41:49 +0100164 PermuteLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100165 PoolingLayer,
Georgios Pinitasf8c47492020-02-04 17:39:59 +0000166 PReluLayer,
Giorgio Arena6e9d0e02020-01-03 15:02:04 +0000167 PrintLayer,
Pablo Tello32521432018-11-15 14:43:10 +0000168 PriorBoxLayer,
Isabella Gottardi3db1ba92019-05-17 12:35:20 +0100169 QuantizationLayer,
Gian Marco Iodice23e24792018-09-07 15:32:14 +0100170 ReorgLayer,
Michalis Spyrou27c9efb2017-10-09 15:46:30 +0100171 ReshapeLayer,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100172 ResizeLayer,
Manuel Bottini3f9d4d72018-10-19 14:04:42 +0100173 ROIAlignLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100174 SoftmaxLayer,
Michele Di Giorgioc30b6682018-09-12 17:44:08 +0100175 SliceLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100176 SplitLayer,
Michele Di Giorgioec699752019-03-22 15:25:32 +0000177 StackLayer,
Michalis Spyrou4e1c3f32018-09-20 17:14:03 +0100178 UpsampleLayer,
Sheri Zhang16dddd22020-05-27 15:03:48 +0100179 UnaryEltwiseLayer,
Michalis Spyrou96f67692018-09-13 11:39:28 +0100180 YOLOLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100181
182 Input,
183 Output,
184 Const,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100185
186 Dummy
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100187};
188
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100189/** Backend Memory Manager affinity **/
190enum class MemoryManagerAffinity
Georgios Pinitase2c82fe2017-10-02 18:51:47 +0100191{
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100192 Buffer, /**< Affinity at buffer level */
193 Offset /**< Affinity at offset level */
194};
195
196/** NodeID-index struct
197 *
198 * Used to describe connections
199 */
200struct NodeIdxPair
201{
202 NodeID node_id; /**< Node ID */
203 size_t index; /**< Index */
204};
205
206/** Common node parameters */
207struct NodeParams
208{
209 std::string name; /**< Node name */
210 Target target; /**< Node target */
Georgios Pinitase2c82fe2017-10-02 18:51:47 +0100211};
Anthony Barbier2a07e182017-08-04 18:20:27 +0100212} // namespace graph
213} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000214#endif /* ARM_COMPUTE_GRAPH_TYPES_H */