Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1 | /* |
Matthew Bentham | f1aeab9 | 2023-05-30 13:35:34 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2021, 2023 Arm Limited. |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 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 | */ |
Jakub Sujak | 0d27b2e | 2023-08-24 14:01:20 +0100 | [diff] [blame^] | 24 | #ifndef ACL_ARM_COMPUTE_GRAPH_TYPES_H |
| 25 | #define ACL_ARM_COMPUTE_GRAPH_TYPES_H |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 26 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 27 | #include "arm_compute/core/Error.h" |
Georgios Pinitas | 102b0ce | 2020-02-13 17:59:09 +0000 | [diff] [blame] | 28 | #include "arm_compute/core/PixelValue.h" |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 29 | #include "arm_compute/core/Types.h" |
SiCong Li | 9129549 | 2023-07-21 18:16:13 +0100 | [diff] [blame] | 30 | #include "arm_compute/function_info/ActivationLayerInfo.h" |
| 31 | #include "arm_compute/function_info/ConvolutionInfo.h" |
| 32 | #include "arm_compute/function_info/FullyConnectedLayerInfo.h" |
| 33 | #include "arm_compute/function_info/GEMMInfo.h" |
Vidhya Sudhan Loganathan | 050471e | 2019-04-25 09:27:24 +0100 | [diff] [blame] | 34 | #include "arm_compute/runtime/CL/CLTunerTypes.h" |
Michalis Spyrou | 402740d | 2021-04-20 11:26:21 +0100 | [diff] [blame] | 35 | #include "arm_compute/runtime/CL/CLTypes.h" |
Georgios Pinitas | 7d3d1b9 | 2017-10-12 17:34:20 +0100 | [diff] [blame] | 36 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 37 | #include <limits> |
| 38 | #include <string> |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 39 | |
| 40 | namespace arm_compute |
| 41 | { |
| 42 | namespace graph |
| 43 | { |
Michalis Spyrou | 402740d | 2021-04-20 11:26:21 +0100 | [diff] [blame] | 44 | using arm_compute::CLBackendType; |
Jakub Sujak | 0d27b2e | 2023-08-24 14:01:20 +0100 | [diff] [blame^] | 45 | using arm_compute::CLTunerMode; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 46 | using arm_compute::Status; |
| 47 | |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame] | 48 | using arm_compute::Coordinates; |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 49 | using arm_compute::DataLayout; |
| 50 | using arm_compute::DataLayoutDimension; |
Jakub Sujak | 0d27b2e | 2023-08-24 14:01:20 +0100 | [diff] [blame^] | 51 | using arm_compute::DataType; |
Georgios Pinitas | 57c4824 | 2018-08-02 13:41:49 +0100 | [diff] [blame] | 52 | using arm_compute::PermutationVector; |
Georgios Pinitas | 102b0ce | 2020-02-13 17:59:09 +0000 | [diff] [blame] | 53 | using arm_compute::PixelValue; |
Jakub Sujak | 0d27b2e | 2023-08-24 14:01:20 +0100 | [diff] [blame^] | 54 | using arm_compute::Size2D; |
| 55 | using arm_compute::TensorShape; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 56 | |
| 57 | using arm_compute::ActivationLayerInfo; |
Isabella Gottardi | 7234ed8 | 2018-11-27 08:51:10 +0000 | [diff] [blame] | 58 | using arm_compute::DetectionOutputLayerInfo; |
Isabella Gottardi | a7acb3c | 2019-01-08 13:48:44 +0000 | [diff] [blame] | 59 | using arm_compute::DetectionPostProcessLayerInfo; |
Jakub Sujak | 0d27b2e | 2023-08-24 14:01:20 +0100 | [diff] [blame^] | 60 | using arm_compute::DimensionRoundingType; |
Georgios Pinitas | c55cef1 | 2018-08-01 15:24:18 +0100 | [diff] [blame] | 61 | using arm_compute::FullyConnectedLayerInfo; |
Jakub Sujak | 0d27b2e | 2023-08-24 14:01:20 +0100 | [diff] [blame^] | 62 | using arm_compute::InterpolationPolicy; |
| 63 | using arm_compute::NormalizationLayerInfo; |
| 64 | using arm_compute::NormType; |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame] | 65 | using arm_compute::PadStrideInfo; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 66 | using arm_compute::PoolingLayerInfo; |
| 67 | using arm_compute::PoolingType; |
Pablo Tello | 3252143 | 2018-11-15 14:43:10 +0000 | [diff] [blame] | 68 | using arm_compute::PriorBoxLayerInfo; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 69 | |
Georgios Pinitas | 54c92fd | 2018-11-05 12:16:15 +0000 | [diff] [blame] | 70 | using GraphID = unsigned int; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 71 | using TensorID = unsigned int; |
| 72 | using NodeID = unsigned int; |
| 73 | using EdgeID = unsigned int; |
| 74 | using Activation = arm_compute::ActivationLayerInfo::ActivationFunction; |
Georgios Pinitas | 7d3d1b9 | 2017-10-12 17:34:20 +0100 | [diff] [blame] | 75 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 76 | /**< Constant TensorID specifying an equivalent of null tensor */ |
| 77 | constexpr TensorID NullTensorID = std::numeric_limits<TensorID>::max(); |
| 78 | /**< Constant NodeID specifying an equivalent of null node */ |
| 79 | constexpr NodeID EmptyNodeID = std::numeric_limits<NodeID>::max(); |
| 80 | /**< Constant EdgeID specifying an equivalent of null edge */ |
| 81 | constexpr EdgeID EmptyEdgeID = std::numeric_limits<EdgeID>::max(); |
| 82 | |
| 83 | // Forward declarations |
Georgios Pinitas | 879d131 | 2019-09-30 13:25:53 +0100 | [diff] [blame] | 84 | struct TensorDescriptor; |
SiCongLi | f466d75 | 2021-03-01 15:26:18 +0000 | [diff] [blame] | 85 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 86 | /** Graph configuration structure */ |
| 87 | struct GraphConfig |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 88 | { |
Michalis Spyrou | 402740d | 2021-04-20 11:26:21 +0100 | [diff] [blame] | 89 | bool use_function_memory_manager{ true }; /**< Use a memory manager to manage per-function auxilary memory */ |
| 90 | bool use_function_weights_manager{ true }; /**< Use a weights manager to manage transformed weights */ |
| 91 | bool use_transition_memory_manager{ true }; /**< Use a memory manager to manager transition buffer memory */ |
| 92 | bool use_tuner{ false }; /**< Use a tuner in tunable backends */ |
| 93 | bool use_synthetic_type{ false }; /**< Convert graph to a synthetic graph for a data type */ |
| 94 | DataType synthetic_type{ DataType::QASYMM8 }; /**< The data type of the synthetic graph */ |
| 95 | CLTunerMode tuner_mode{ CLTunerMode::EXHAUSTIVE }; /**< Tuner mode to be used by the CL tuner */ |
| 96 | 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. */ |
| 97 | std::string tuner_file{ "acl_tuner.csv" }; /**< File to load/store tuning values from */ |
| 98 | std::string mlgo_file{ "heuristics.mlgo" }; /**< Filename to load MLGO heuristics from */ |
| 99 | CLBackendType backend_type{ CLBackendType::Native }; /**< CL backend type to use */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 100 | }; |
| 101 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 102 | /**< Device target types */ |
| 103 | enum class Target |
| 104 | { |
| 105 | UNSPECIFIED, /**< Unspecified Target */ |
Michele Di Giorgio | 33f41fa | 2021-03-09 14:09:08 +0000 | [diff] [blame] | 106 | NEON, /**< Arm® Neon™ capable target device */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 107 | CL, /**< OpenCL capable target device */ |
Michalis Spyrou | 402740d | 2021-04-20 11:26:21 +0100 | [diff] [blame] | 108 | CLVK, /**< CLVK capable target device */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | /** Supported Element-wise operations */ |
| 112 | enum class EltwiseOperation |
| 113 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 114 | Add, /**< Arithmetic addition */ |
| 115 | Sub, /**< Arithmetic subtraction */ |
Sheri Zhang | 16dddd2 | 2020-05-27 15:03:48 +0100 | [diff] [blame] | 116 | Mul, /**< Arithmetic multiplication */ |
thecha01 | f8e3584 | 2020-07-28 17:28:17 +0100 | [diff] [blame] | 117 | Max, /**< Arithmetic maximum */ |
Alessandro Navone | 6413e49 | 2021-02-02 11:39:05 +0000 | [diff] [blame] | 118 | Div, /**< Arithmetic division */ |
Sheri Zhang | 1d35927 | 2021-06-10 13:56:11 +0100 | [diff] [blame] | 119 | Min, /**< Arithmetic minimum */ |
Sheri Zhang | 16dddd2 | 2020-05-27 15:03:48 +0100 | [diff] [blame] | 120 | }; |
| 121 | |
| 122 | /** Supported Unary Element-wise operations */ |
| 123 | enum class UnaryEltwiseOperation |
| 124 | { |
| 125 | Exp /**< Exp */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | /** Supported Convolution layer methods */ |
| 129 | enum class ConvolutionMethod |
| 130 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 131 | Default, /**< Default approach using internal heuristics */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 132 | GEMM, /**< GEMM based convolution */ |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 133 | Direct, /**< Deep direct convolution */ |
| 134 | Winograd /**< Winograd based convolution */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | /** Supported Depthwise Convolution layer methods */ |
| 138 | enum class DepthwiseConvolutionMethod |
| 139 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 140 | Default, /**< Default approach using internal heuristics */ |
| 141 | GEMV, /**< Generic GEMV based depthwise convolution */ |
| 142 | Optimized3x3, /**< Optimized 3x3 direct depthwise convolution */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 143 | }; |
| 144 | |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 145 | /** Enable or disable fast math for Convolution layer */ |
| 146 | enum class FastMathHint |
| 147 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 148 | Enabled, /**< Fast math enabled for Convolution layer */ |
| 149 | Disabled, /**< Fast math disabled for Convolution layer */ |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 150 | }; |
| 151 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 152 | /** Supported nodes */ |
| 153 | enum class NodeType |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 154 | { |
| 155 | ActivationLayer, |
thecha01 | e8f05da | 2020-08-24 17:21:41 +0100 | [diff] [blame] | 156 | ArgMinMaxLayer, |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 157 | BatchNormalizationLayer, |
Manuel Bottini | d2048ce | 2018-10-23 17:00:42 +0100 | [diff] [blame] | 158 | BoundingBoxTransformLayer, |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 159 | ChannelShuffleLayer, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 160 | ConcatenateLayer, |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 161 | ConvolutionLayer, |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 162 | DeconvolutionLayer, |
thecha01 | 0a05e6a | 2020-08-28 18:40:38 +0100 | [diff] [blame] | 163 | DepthToSpaceLayer, |
Michalis Spyrou | 7bfe4c5 | 2017-11-24 09:54:20 +0000 | [diff] [blame] | 164 | DepthwiseConvolutionLayer, |
Isabella Gottardi | cd4e9ab | 2019-11-05 17:50:27 +0000 | [diff] [blame] | 165 | DequantizationLayer, |
Isabella Gottardi | 7234ed8 | 2018-11-27 08:51:10 +0000 | [diff] [blame] | 166 | DetectionOutputLayer, |
Isabella Gottardi | a7acb3c | 2019-01-08 13:48:44 +0000 | [diff] [blame] | 167 | DetectionPostProcessLayer, |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 168 | EltwiseLayer, |
Michalis Spyrou | 27c9efb | 2017-10-09 15:46:30 +0100 | [diff] [blame] | 169 | FlattenLayer, |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 170 | FullyConnectedLayer, |
giuros01 | acce504 | 2019-02-21 17:32:34 +0000 | [diff] [blame] | 171 | FusedConvolutionBatchNormalizationLayer, |
Manuel Bottini | bffb41e | 2019-06-20 16:00:27 +0100 | [diff] [blame] | 172 | FusedDepthwiseConvolutionBatchNormalizationLayer, |
Manuel Bottini | 5209be5 | 2019-02-13 16:34:56 +0000 | [diff] [blame] | 173 | GenerateProposalsLayer, |
thecha01 | 3603aff | 2020-09-01 14:52:38 +0100 | [diff] [blame] | 174 | L2NormalizeLayer, |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 175 | NormalizationLayer, |
Michele Di Giorgio | 555d110 | 2018-09-12 13:51:59 +0100 | [diff] [blame] | 176 | NormalizePlanarYUVLayer, |
Michele Di Giorgio | 4bb1733 | 2018-09-26 13:56:51 +0100 | [diff] [blame] | 177 | PadLayer, |
Georgios Pinitas | 57c4824 | 2018-08-02 13:41:49 +0100 | [diff] [blame] | 178 | PermuteLayer, |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 179 | PoolingLayer, |
Georgios Pinitas | f8c4749 | 2020-02-04 17:39:59 +0000 | [diff] [blame] | 180 | PReluLayer, |
Giorgio Arena | 6e9d0e0 | 2020-01-03 15:02:04 +0000 | [diff] [blame] | 181 | PrintLayer, |
Pablo Tello | 3252143 | 2018-11-15 14:43:10 +0000 | [diff] [blame] | 182 | PriorBoxLayer, |
Isabella Gottardi | 3db1ba9 | 2019-05-17 12:35:20 +0100 | [diff] [blame] | 183 | QuantizationLayer, |
thecha01 | d64444b | 2020-09-07 14:50:21 +0100 | [diff] [blame] | 184 | ReductionOperationLayer, |
Gian Marco Iodice | 23e2479 | 2018-09-07 15:32:14 +0100 | [diff] [blame] | 185 | ReorgLayer, |
Michalis Spyrou | 27c9efb | 2017-10-09 15:46:30 +0100 | [diff] [blame] | 186 | ReshapeLayer, |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 187 | ResizeLayer, |
Manuel Bottini | 3f9d4d7 | 2018-10-19 14:04:42 +0100 | [diff] [blame] | 188 | ROIAlignLayer, |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 189 | SoftmaxLayer, |
Michele Di Giorgio | c30b668 | 2018-09-12 17:44:08 +0100 | [diff] [blame] | 190 | SliceLayer, |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 191 | SplitLayer, |
Michele Di Giorgio | ec69975 | 2019-03-22 15:25:32 +0000 | [diff] [blame] | 192 | StackLayer, |
thecha01 | 2bfadd9 | 2020-08-12 17:25:51 +0100 | [diff] [blame] | 193 | StridedSliceLayer, |
Michalis Spyrou | 4e1c3f3 | 2018-09-20 17:14:03 +0100 | [diff] [blame] | 194 | UpsampleLayer, |
Sheri Zhang | 16dddd2 | 2020-05-27 15:03:48 +0100 | [diff] [blame] | 195 | UnaryEltwiseLayer, |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 196 | |
| 197 | Input, |
| 198 | Output, |
| 199 | Const, |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 200 | |
| 201 | Dummy |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 202 | }; |
| 203 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 204 | /** Backend Memory Manager affinity **/ |
| 205 | enum class MemoryManagerAffinity |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame] | 206 | { |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 207 | Buffer, /**< Affinity at buffer level */ |
| 208 | Offset /**< Affinity at offset level */ |
| 209 | }; |
| 210 | |
| 211 | /** NodeID-index struct |
| 212 | * |
| 213 | * Used to describe connections |
| 214 | */ |
| 215 | struct NodeIdxPair |
| 216 | { |
| 217 | NodeID node_id; /**< Node ID */ |
| 218 | size_t index; /**< Index */ |
| 219 | }; |
| 220 | |
| 221 | /** Common node parameters */ |
| 222 | struct NodeParams |
| 223 | { |
| 224 | std::string name; /**< Node name */ |
| 225 | Target target; /**< Node target */ |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame] | 226 | }; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 227 | } // namespace graph |
| 228 | } // namespace arm_compute |
Jakub Sujak | 0d27b2e | 2023-08-24 14:01:20 +0100 | [diff] [blame^] | 229 | #endif // ACL_ARM_COMPUTE_GRAPH_TYPES_H |