Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1 | /* |
Giuseppe Rossini | bb365de | 2019-02-15 10:24:47 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2019 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 | */ |
| 24 | #ifndef __ARM_COMPUTE_GRAPH_TYPES_H__ |
| 25 | #define __ARM_COMPUTE_GRAPH_TYPES_H__ |
| 26 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 27 | #include "arm_compute/core/Error.h" |
| 28 | #include "arm_compute/core/Types.h" |
Vidhya Sudhan Loganathan | 050471e | 2019-04-25 09:27:24 +0100 | [diff] [blame] | 29 | #include "arm_compute/runtime/CL/CLTunerTypes.h" |
Georgios Pinitas | 7d3d1b9 | 2017-10-12 17:34:20 +0100 | [diff] [blame] | 30 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 31 | #include <limits> |
| 32 | #include <string> |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 33 | |
| 34 | namespace arm_compute |
| 35 | { |
| 36 | namespace graph |
| 37 | { |
Vidhya Sudhan Loganathan | 050471e | 2019-04-25 09:27:24 +0100 | [diff] [blame] | 38 | using arm_compute::CLTunerMode; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 39 | using arm_compute::Status; |
| 40 | |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame] | 41 | using arm_compute::Coordinates; |
| 42 | using arm_compute::DataType; |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 43 | using arm_compute::DataLayout; |
| 44 | using arm_compute::DataLayoutDimension; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 45 | using arm_compute::TensorShape; |
| 46 | using arm_compute::Size2D; |
Georgios Pinitas | 57c4824 | 2018-08-02 13:41:49 +0100 | [diff] [blame] | 47 | using arm_compute::PermutationVector; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 48 | |
| 49 | using arm_compute::ActivationLayerInfo; |
Isabella Gottardi | 7234ed8 | 2018-11-27 08:51:10 +0000 | [diff] [blame] | 50 | using arm_compute::DetectionOutputLayerInfo; |
Isabella Gottardi | a7acb3c | 2019-01-08 13:48:44 +0000 | [diff] [blame] | 51 | using arm_compute::DetectionPostProcessLayerInfo; |
Georgios Pinitas | 6f669f0 | 2017-09-26 12:32:57 +0100 | [diff] [blame] | 52 | using arm_compute::NormType; |
| 53 | using arm_compute::NormalizationLayerInfo; |
Georgios Pinitas | c55cef1 | 2018-08-01 15:24:18 +0100 | [diff] [blame] | 54 | using arm_compute::FullyConnectedLayerInfo; |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame] | 55 | using arm_compute::PadStrideInfo; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 56 | using arm_compute::PoolingLayerInfo; |
| 57 | using arm_compute::PoolingType; |
Pablo Tello | 3252143 | 2018-11-15 14:43:10 +0000 | [diff] [blame] | 58 | using arm_compute::PriorBoxLayerInfo; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 59 | using arm_compute::DimensionRoundingType; |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 60 | using arm_compute::InterpolationPolicy; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 61 | |
Georgios Pinitas | 54c92fd | 2018-11-05 12:16:15 +0000 | [diff] [blame] | 62 | using GraphID = unsigned int; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 63 | using TensorID = unsigned int; |
| 64 | using NodeID = unsigned int; |
| 65 | using EdgeID = unsigned int; |
| 66 | using Activation = arm_compute::ActivationLayerInfo::ActivationFunction; |
Georgios Pinitas | 7d3d1b9 | 2017-10-12 17:34:20 +0100 | [diff] [blame] | 67 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 68 | /**< Constant TensorID specifying an equivalent of null tensor */ |
| 69 | constexpr TensorID NullTensorID = std::numeric_limits<TensorID>::max(); |
| 70 | /**< Constant NodeID specifying an equivalent of null node */ |
| 71 | constexpr NodeID EmptyNodeID = std::numeric_limits<NodeID>::max(); |
| 72 | /**< Constant EdgeID specifying an equivalent of null edge */ |
| 73 | constexpr EdgeID EmptyEdgeID = std::numeric_limits<EdgeID>::max(); |
| 74 | |
| 75 | // Forward declarations |
| 76 | class TensorDescriptor; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 77 | /** Graph configuration structure */ |
| 78 | struct GraphConfig |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 79 | { |
Anthony Barbier | 7b607dc | 2018-07-13 15:55:24 +0100 | [diff] [blame] | 80 | bool use_function_memory_manager{ true }; /**< Use a memory manager to manage per-funcion auxilary memory */ |
| 81 | bool use_transition_memory_manager{ true }; /**< Use a memory manager to manager transition buffer memory */ |
| 82 | bool use_tuner{ false }; /**< Use a tuner in tunable backends */ |
Vidhya Sudhan Loganathan | 050471e | 2019-04-25 09:27:24 +0100 | [diff] [blame] | 83 | CLTunerMode tuner_mode{ CLTunerMode::EXHAUSTIVE }; /**< Tuner mode to be used by the CL tuner */ |
Anthony Barbier | 7b607dc | 2018-07-13 15:55:24 +0100 | [diff] [blame] | 84 | 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. */ |
| 85 | std::string tuner_file{ "acl_tuner.csv" }; /**< File to load/store tuning values from */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 86 | }; |
| 87 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 88 | /**< Device target types */ |
| 89 | enum class Target |
| 90 | { |
| 91 | UNSPECIFIED, /**< Unspecified Target */ |
| 92 | NEON, /**< NEON capable target device */ |
| 93 | CL, /**< OpenCL capable target device */ |
| 94 | GC, /**< GLES compute capable target device */ |
| 95 | }; |
| 96 | |
| 97 | /** Supported Element-wise operations */ |
| 98 | enum class EltwiseOperation |
| 99 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 100 | Add, /**< Arithmetic addition */ |
| 101 | Sub, /**< Arithmetic subtraction */ |
| 102 | Mul /**< Arithmetic multiplication */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | /** Supported Convolution layer methods */ |
| 106 | enum class ConvolutionMethod |
| 107 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 108 | Default, /**< Default approach using internal heuristics */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 109 | GEMM, /**< GEMM based convolution */ |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 110 | Direct, /**< Deep direct convolution */ |
| 111 | Winograd /**< Winograd based convolution */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | /** Supported Depthwise Convolution layer methods */ |
| 115 | enum class DepthwiseConvolutionMethod |
| 116 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 117 | Default, /**< Default approach using internal heuristics */ |
| 118 | GEMV, /**< Generic GEMV based depthwise convolution */ |
| 119 | Optimized3x3, /**< Optimized 3x3 direct depthwise convolution */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 120 | }; |
| 121 | |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 122 | /** Enable or disable fast math for Convolution layer */ |
| 123 | enum class FastMathHint |
| 124 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 125 | Enabled, /**< Fast math enabled for Convolution layer */ |
| 126 | Disabled, /**< Fast math disabled for Convolution layer */ |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 127 | }; |
| 128 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 129 | /** Supported nodes */ |
| 130 | enum class NodeType |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 131 | { |
| 132 | ActivationLayer, |
| 133 | BatchNormalizationLayer, |
Manuel Bottini | d2048ce | 2018-10-23 17:00:42 +0100 | [diff] [blame] | 134 | BoundingBoxTransformLayer, |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 135 | ChannelShuffleLayer, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 136 | ConcatenateLayer, |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 137 | ConvolutionLayer, |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 138 | DeconvolutionLayer, |
Michalis Spyrou | 7bfe4c5 | 2017-11-24 09:54:20 +0000 | [diff] [blame] | 139 | DepthwiseConvolutionLayer, |
Isabella Gottardi | 7234ed8 | 2018-11-27 08:51:10 +0000 | [diff] [blame] | 140 | DetectionOutputLayer, |
Isabella Gottardi | a7acb3c | 2019-01-08 13:48:44 +0000 | [diff] [blame] | 141 | DetectionPostProcessLayer, |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 142 | EltwiseLayer, |
Michalis Spyrou | 27c9efb | 2017-10-09 15:46:30 +0100 | [diff] [blame] | 143 | FlattenLayer, |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 144 | FullyConnectedLayer, |
giuros01 | acce504 | 2019-02-21 17:32:34 +0000 | [diff] [blame] | 145 | FusedConvolutionBatchNormalizationLayer, |
Manuel Bottini | bffb41e | 2019-06-20 16:00:27 +0100 | [diff] [blame] | 146 | FusedDepthwiseConvolutionBatchNormalizationLayer, |
Manuel Bottini | 5209be5 | 2019-02-13 16:34:56 +0000 | [diff] [blame] | 147 | GenerateProposalsLayer, |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 148 | NormalizationLayer, |
Michele Di Giorgio | 555d110 | 2018-09-12 13:51:59 +0100 | [diff] [blame] | 149 | NormalizePlanarYUVLayer, |
Michele Di Giorgio | 4bb1733 | 2018-09-26 13:56:51 +0100 | [diff] [blame] | 150 | PadLayer, |
Georgios Pinitas | 57c4824 | 2018-08-02 13:41:49 +0100 | [diff] [blame] | 151 | PermuteLayer, |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 152 | PoolingLayer, |
Pablo Tello | 3252143 | 2018-11-15 14:43:10 +0000 | [diff] [blame] | 153 | PriorBoxLayer, |
Isabella Gottardi | 3db1ba9 | 2019-05-17 12:35:20 +0100 | [diff] [blame] | 154 | QuantizationLayer, |
Gian Marco Iodice | 23e2479 | 2018-09-07 15:32:14 +0100 | [diff] [blame] | 155 | ReorgLayer, |
Michalis Spyrou | 27c9efb | 2017-10-09 15:46:30 +0100 | [diff] [blame] | 156 | ReshapeLayer, |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 157 | ResizeLayer, |
Manuel Bottini | 3f9d4d7 | 2018-10-19 14:04:42 +0100 | [diff] [blame] | 158 | ROIAlignLayer, |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 159 | SoftmaxLayer, |
Michele Di Giorgio | c30b668 | 2018-09-12 17:44:08 +0100 | [diff] [blame] | 160 | SliceLayer, |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 161 | SplitLayer, |
Michele Di Giorgio | ec69975 | 2019-03-22 15:25:32 +0000 | [diff] [blame] | 162 | StackLayer, |
Michalis Spyrou | 4e1c3f3 | 2018-09-20 17:14:03 +0100 | [diff] [blame] | 163 | UpsampleLayer, |
Michalis Spyrou | 96f6769 | 2018-09-13 11:39:28 +0100 | [diff] [blame] | 164 | YOLOLayer, |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 165 | |
| 166 | Input, |
| 167 | Output, |
| 168 | Const, |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 169 | |
| 170 | Dummy |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 171 | }; |
| 172 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 173 | /** Backend Memory Manager affinity **/ |
| 174 | enum class MemoryManagerAffinity |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame] | 175 | { |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 176 | Buffer, /**< Affinity at buffer level */ |
| 177 | Offset /**< Affinity at offset level */ |
| 178 | }; |
| 179 | |
| 180 | /** NodeID-index struct |
| 181 | * |
| 182 | * Used to describe connections |
| 183 | */ |
| 184 | struct NodeIdxPair |
| 185 | { |
| 186 | NodeID node_id; /**< Node ID */ |
| 187 | size_t index; /**< Index */ |
| 188 | }; |
| 189 | |
| 190 | /** Common node parameters */ |
| 191 | struct NodeParams |
| 192 | { |
| 193 | std::string name; /**< Node name */ |
| 194 | Target target; /**< Node target */ |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame] | 195 | }; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 196 | } // namespace graph |
| 197 | } // namespace arm_compute |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 198 | #endif /* __ARM_COMPUTE_GRAPH_TYPES_H__ */ |