blob: c01f9a8f4ed0a68d6ebb18a4703122385d16c730 [file] [log] [blame]
Anthony Barbier2a07e182017-08-04 18:20:27 +01001/*
Giuseppe Rossinibb365de2019-02-15 10:24:47 +00002 * Copyright (c) 2018-2019 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 */
24#ifndef __ARM_COMPUTE_GRAPH_TYPES_H__
25#define __ARM_COMPUTE_GRAPH_TYPES_H__
26
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010027#include "arm_compute/core/Error.h"
28#include "arm_compute/core/Types.h"
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010029#include "arm_compute/runtime/CL/CLTunerTypes.h"
Georgios Pinitas7d3d1b92017-10-12 17:34:20 +010030
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010031#include <limits>
32#include <string>
Anthony Barbier2a07e182017-08-04 18:20:27 +010033
34namespace arm_compute
35{
36namespace graph
37{
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010038using arm_compute::CLTunerMode;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010039using arm_compute::Status;
40
Georgios Pinitase2c82fe2017-10-02 18:51:47 +010041using arm_compute::Coordinates;
42using arm_compute::DataType;
Georgios Pinitascac13b12018-04-27 19:07:19 +010043using arm_compute::DataLayout;
44using arm_compute::DataLayoutDimension;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010045using arm_compute::TensorShape;
46using arm_compute::Size2D;
Georgios Pinitas57c48242018-08-02 13:41:49 +010047using arm_compute::PermutationVector;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010048
49using arm_compute::ActivationLayerInfo;
Isabella Gottardi7234ed82018-11-27 08:51:10 +000050using arm_compute::DetectionOutputLayerInfo;
Isabella Gottardia7acb3c2019-01-08 13:48:44 +000051using arm_compute::DetectionPostProcessLayerInfo;
Georgios Pinitas6f669f02017-09-26 12:32:57 +010052using arm_compute::NormType;
53using arm_compute::NormalizationLayerInfo;
Georgios Pinitasc55cef12018-08-01 15:24:18 +010054using arm_compute::FullyConnectedLayerInfo;
Georgios Pinitase2c82fe2017-10-02 18:51:47 +010055using arm_compute::PadStrideInfo;
Anthony Barbier2a07e182017-08-04 18:20:27 +010056using arm_compute::PoolingLayerInfo;
57using arm_compute::PoolingType;
Pablo Tello32521432018-11-15 14:43:10 +000058using arm_compute::PriorBoxLayerInfo;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010059using arm_compute::DimensionRoundingType;
Georgios Pinitas087eaf62018-05-16 15:52:35 +010060using arm_compute::InterpolationPolicy;
Anthony Barbier2a07e182017-08-04 18:20:27 +010061
Georgios Pinitas54c92fd2018-11-05 12:16:15 +000062using GraphID = unsigned int;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010063using TensorID = unsigned int;
64using NodeID = unsigned int;
65using EdgeID = unsigned int;
66using Activation = arm_compute::ActivationLayerInfo::ActivationFunction;
Georgios Pinitas7d3d1b92017-10-12 17:34:20 +010067
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010068/**< Constant TensorID specifying an equivalent of null tensor */
69constexpr TensorID NullTensorID = std::numeric_limits<TensorID>::max();
70/**< Constant NodeID specifying an equivalent of null node */
71constexpr NodeID EmptyNodeID = std::numeric_limits<NodeID>::max();
72/**< Constant EdgeID specifying an equivalent of null edge */
73constexpr EdgeID EmptyEdgeID = std::numeric_limits<EdgeID>::max();
74
75// Forward declarations
Georgios Pinitas879d1312019-09-30 13:25:53 +010076struct TensorDescriptor;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010077/** Graph configuration structure */
78struct GraphConfig
Anthony Barbier2a07e182017-08-04 18:20:27 +010079{
Anthony Barbier7b607dc2018-07-13 15:55:24 +010080 bool use_function_memory_manager{ true }; /**< Use a memory manager to manage per-funcion auxilary memory */
Michalis Spyrou1a569a32019-09-10 17:20:34 +010081 bool use_function_weights_manager{ true }; /**< Use a weights manager to manage transformed weights */
Anthony Barbier7b607dc2018-07-13 15:55:24 +010082 bool use_transition_memory_manager{ true }; /**< Use a memory manager to manager transition buffer memory */
83 bool use_tuner{ false }; /**< Use a tuner in tunable backends */
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010084 CLTunerMode tuner_mode{ CLTunerMode::EXHAUSTIVE }; /**< Tuner mode to be used by the CL tuner */
Anthony Barbier7b607dc2018-07-13 15:55:24 +010085 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. */
86 std::string tuner_file{ "acl_tuner.csv" }; /**< File to load/store tuning values from */
Anthony Barbier2a07e182017-08-04 18:20:27 +010087};
88
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010089/**< Device target types */
90enum class Target
91{
92 UNSPECIFIED, /**< Unspecified Target */
93 NEON, /**< NEON capable target device */
94 CL, /**< OpenCL capable target device */
95 GC, /**< GLES compute capable target device */
96};
97
98/** Supported Element-wise operations */
99enum class EltwiseOperation
100{
Georgios Pinitase2220552018-07-20 13:23:44 +0100101 Add, /**< Arithmetic addition */
102 Sub, /**< Arithmetic subtraction */
103 Mul /**< Arithmetic multiplication */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100104};
105
106/** Supported Convolution layer methods */
107enum class ConvolutionMethod
108{
Georgios Pinitase2220552018-07-20 13:23:44 +0100109 Default, /**< Default approach using internal heuristics */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100110 GEMM, /**< GEMM based convolution */
Georgios Pinitase2220552018-07-20 13:23:44 +0100111 Direct, /**< Deep direct convolution */
112 Winograd /**< Winograd based convolution */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100113};
114
115/** Supported Depthwise Convolution layer methods */
116enum class DepthwiseConvolutionMethod
117{
Georgios Pinitase2220552018-07-20 13:23:44 +0100118 Default, /**< Default approach using internal heuristics */
119 GEMV, /**< Generic GEMV based depthwise convolution */
120 Optimized3x3, /**< Optimized 3x3 direct depthwise convolution */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100121};
122
Giorgio Arena59631a12018-05-02 13:59:04 +0100123/** Enable or disable fast math for Convolution layer */
124enum class FastMathHint
125{
Georgios Pinitase2220552018-07-20 13:23:44 +0100126 Enabled, /**< Fast math enabled for Convolution layer */
127 Disabled, /**< Fast math disabled for Convolution layer */
Giorgio Arena59631a12018-05-02 13:59:04 +0100128};
129
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100130/** Supported nodes */
131enum class NodeType
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100132{
133 ActivationLayer,
134 BatchNormalizationLayer,
Manuel Bottinid2048ce2018-10-23 17:00:42 +0100135 BoundingBoxTransformLayer,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100136 ChannelShuffleLayer,
Georgios Pinitase2220552018-07-20 13:23:44 +0100137 ConcatenateLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100138 ConvolutionLayer,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100139 DeconvolutionLayer,
Michalis Spyrou7bfe4c52017-11-24 09:54:20 +0000140 DepthwiseConvolutionLayer,
Isabella Gottardicd4e9ab2019-11-05 17:50:27 +0000141 DequantizationLayer,
Isabella Gottardi7234ed82018-11-27 08:51:10 +0000142 DetectionOutputLayer,
Isabella Gottardia7acb3c2019-01-08 13:48:44 +0000143 DetectionPostProcessLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100144 EltwiseLayer,
Michalis Spyrou27c9efb2017-10-09 15:46:30 +0100145 FlattenLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100146 FullyConnectedLayer,
giuros01acce5042019-02-21 17:32:34 +0000147 FusedConvolutionBatchNormalizationLayer,
Manuel Bottinibffb41e2019-06-20 16:00:27 +0100148 FusedDepthwiseConvolutionBatchNormalizationLayer,
Manuel Bottini5209be52019-02-13 16:34:56 +0000149 GenerateProposalsLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100150 NormalizationLayer,
Michele Di Giorgio555d1102018-09-12 13:51:59 +0100151 NormalizePlanarYUVLayer,
Michele Di Giorgio4bb17332018-09-26 13:56:51 +0100152 PadLayer,
Georgios Pinitas57c48242018-08-02 13:41:49 +0100153 PermuteLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100154 PoolingLayer,
Pablo Tello32521432018-11-15 14:43:10 +0000155 PriorBoxLayer,
Isabella Gottardi3db1ba92019-05-17 12:35:20 +0100156 QuantizationLayer,
Gian Marco Iodice23e24792018-09-07 15:32:14 +0100157 ReorgLayer,
Michalis Spyrou27c9efb2017-10-09 15:46:30 +0100158 ReshapeLayer,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100159 ResizeLayer,
Manuel Bottini3f9d4d72018-10-19 14:04:42 +0100160 ROIAlignLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100161 SoftmaxLayer,
Michele Di Giorgioc30b6682018-09-12 17:44:08 +0100162 SliceLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100163 SplitLayer,
Michele Di Giorgioec699752019-03-22 15:25:32 +0000164 StackLayer,
Michalis Spyrou4e1c3f32018-09-20 17:14:03 +0100165 UpsampleLayer,
Michalis Spyrou96f67692018-09-13 11:39:28 +0100166 YOLOLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100167
168 Input,
169 Output,
170 Const,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100171
172 Dummy
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100173};
174
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100175/** Backend Memory Manager affinity **/
176enum class MemoryManagerAffinity
Georgios Pinitase2c82fe2017-10-02 18:51:47 +0100177{
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100178 Buffer, /**< Affinity at buffer level */
179 Offset /**< Affinity at offset level */
180};
181
182/** NodeID-index struct
183 *
184 * Used to describe connections
185 */
186struct NodeIdxPair
187{
188 NodeID node_id; /**< Node ID */
189 size_t index; /**< Index */
190};
191
192/** Common node parameters */
193struct NodeParams
194{
195 std::string name; /**< Node name */
196 Target target; /**< Node target */
Georgios Pinitase2c82fe2017-10-02 18:51:47 +0100197};
Anthony Barbier2a07e182017-08-04 18:20:27 +0100198} // namespace graph
199} // namespace arm_compute
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100200#endif /* __ARM_COMPUTE_GRAPH_TYPES_H__ */