Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
Teresa Charlin | 50de4fa | 2021-05-31 18:47:33 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | #pragma once |
| 6 | |
| 7 | #include <array> |
Matthew Bentham | 47bfac4 | 2019-03-25 12:30:56 +0000 | [diff] [blame] | 8 | #include <functional> |
janeil01 | c4946c7 | 2019-11-07 09:32:28 +0000 | [diff] [blame] | 9 | #include <stdint.h> |
Keith Davis | e813d67 | 2021-04-22 10:10:34 +0100 | [diff] [blame] | 10 | #include <chrono> |
Jim Flynn | 44db7c3 | 2019-03-22 15:58:39 +0000 | [diff] [blame] | 11 | #include "BackendId.hpp" |
| 12 | #include "Exceptions.hpp" |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 13 | #include "Deprecated.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 14 | |
| 15 | namespace armnn |
| 16 | { |
| 17 | |
Matthew Jackson | dba634f | 2019-08-15 15:14:18 +0100 | [diff] [blame] | 18 | constexpr unsigned int MaxNumOfTensorDimensions = 5U; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 19 | |
Ryan OShea | 2bbfaa7 | 2020-02-12 16:15:27 +0000 | [diff] [blame] | 20 | /// The lowest performance data capture interval we support is 10 miliseconds. |
Colm Donelan | 0270524 | 2019-11-14 14:19:07 +0000 | [diff] [blame] | 21 | constexpr unsigned int LOWEST_CAPTURE_PERIOD = 10000u; |
| 22 | |
Keith Davis | e813d67 | 2021-04-22 10:10:34 +0100 | [diff] [blame] | 23 | /// Variable to control expire rate of priority queue |
| 24 | constexpr unsigned int EXPIRE_RATE = 3U; |
| 25 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 26 | /// @enum Status enumeration |
| 27 | /// @var Status::Successful |
| 28 | /// @var Status::Failure |
| 29 | enum class Status |
| 30 | { |
| 31 | Success = 0, |
| 32 | Failure = 1 |
| 33 | }; |
| 34 | |
| 35 | enum class DataType |
| 36 | { |
Keith Davis | e813d67 | 2021-04-22 10:10:34 +0100 | [diff] [blame] | 37 | Float16 = 0, |
| 38 | Float32 = 1, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 39 | QAsymmU8 = 2, |
ruoyan01 | 20e984f | 2018-12-12 18:11:25 +0000 | [diff] [blame] | 40 | Signed32 = 3, |
Keith Davis | e813d67 | 2021-04-22 10:10:34 +0100 | [diff] [blame] | 41 | Boolean = 4, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 42 | QSymmS16 = 5, |
Jan Eilers | 1b2654f | 2021-09-24 15:45:46 +0100 | [diff] [blame] | 43 | QSymmS8 = 6, |
| 44 | QAsymmS8 = 7, |
| 45 | BFloat16 = 8, |
| 46 | Signed64 = 9, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
Derek Lamberti | 0cff163 | 2018-09-18 16:02:25 +0100 | [diff] [blame] | 49 | enum class DataLayout |
| 50 | { |
| 51 | NCHW = 1, |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 52 | NHWC = 2, |
Matthew Sloyan | 5d7b0a3 | 2021-10-18 13:07:49 +0100 | [diff] [blame] | 53 | NDHWC = 3, |
| 54 | NCDHW = 4 |
Derek Lamberti | 0cff163 | 2018-09-18 16:02:25 +0100 | [diff] [blame] | 55 | }; |
| 56 | |
Keith Davis | 4914d0c | 2021-08-18 17:14:05 +0100 | [diff] [blame] | 57 | /// Define the behaviour of the internal profiler when outputting network details |
| 58 | enum class ProfilingDetailsMethod |
| 59 | { |
| 60 | Undefined = 0, |
| 61 | DetailsWithEvents = 1, |
| 62 | DetailsOnly = 2 |
| 63 | }; |
| 64 | |
| 65 | |
Keith Davis | e813d67 | 2021-04-22 10:10:34 +0100 | [diff] [blame] | 66 | enum class QosExecPriority |
| 67 | { |
| 68 | Low = 0, |
| 69 | Medium = 1, |
| 70 | High = 2 |
| 71 | }; |
| 72 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 73 | enum class ActivationFunction |
| 74 | { |
| 75 | Sigmoid = 0, |
| 76 | TanH = 1, |
| 77 | Linear = 2, |
| 78 | ReLu = 3, |
Colm Donelan | 03fbeaf | 2020-02-26 15:39:23 +0000 | [diff] [blame] | 79 | BoundedReLu = 4, ///< min(a, max(b, input)) ReLu1 & ReLu6. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 80 | SoftReLu = 5, |
| 81 | LeakyReLu = 6, |
| 82 | Abs = 7, |
| 83 | Sqrt = 8, |
David Monahan | 3b3c381 | 2020-02-25 09:03:29 +0000 | [diff] [blame] | 84 | Square = 9, |
Colm Donelan | 03fbeaf | 2020-02-26 15:39:23 +0000 | [diff] [blame] | 85 | Elu = 10, |
| 86 | HardSwish = 11 |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 87 | }; |
| 88 | |
Narumol Prangnawarat | 8d001d4 | 2019-09-09 15:01:18 +0100 | [diff] [blame] | 89 | enum class ArgMinMaxFunction |
| 90 | { |
| 91 | Min = 0, |
| 92 | Max = 1 |
| 93 | }; |
| 94 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 95 | enum class ComparisonOperation |
| 96 | { |
| 97 | Equal = 0, |
| 98 | Greater = 1, |
| 99 | GreaterOrEqual = 2, |
| 100 | Less = 3, |
| 101 | LessOrEqual = 4, |
| 102 | NotEqual = 5 |
| 103 | }; |
| 104 | |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 105 | enum class LogicalBinaryOperation |
| 106 | { |
| 107 | LogicalAnd = 0, |
| 108 | LogicalOr = 1 |
| 109 | }; |
| 110 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 111 | enum class UnaryOperation |
| 112 | { |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 113 | Abs = 0, |
| 114 | Exp = 1, |
| 115 | Sqrt = 2, |
| 116 | Rsqrt = 3, |
| 117 | Neg = 4, |
Teresa Charlin | 50de4fa | 2021-05-31 18:47:33 +0100 | [diff] [blame] | 118 | LogicalNot = 5, |
| 119 | Log = 6, |
| 120 | Sin = 7 |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 121 | }; |
| 122 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 123 | enum class PoolingAlgorithm |
| 124 | { |
| 125 | Max = 0, |
| 126 | Average = 1, |
| 127 | L2 = 2 |
| 128 | }; |
| 129 | |
Sadik Armagan | 0c3ea5b | 2021-02-03 09:29:30 +0000 | [diff] [blame] | 130 | enum class ReduceOperation |
| 131 | { |
| 132 | Sum = 0, |
| 133 | Max = 1, |
| 134 | Mean = 2, |
Teresa Charlin | 4e3e831 | 2021-08-05 12:34:37 +0100 | [diff] [blame] | 135 | Min = 3, |
| 136 | Prod = 4 |
Sadik Armagan | 0c3ea5b | 2021-02-03 09:29:30 +0000 | [diff] [blame] | 137 | }; |
| 138 | |
Teresa Charlin | a9075df | 2019-06-27 15:41:57 +0100 | [diff] [blame] | 139 | enum class ResizeMethod |
| 140 | { |
| 141 | Bilinear = 0, |
| 142 | NearestNeighbor = 1 |
| 143 | }; |
| 144 | |
Teresa Charlin | 11f6ace | 2020-06-23 18:30:57 +0100 | [diff] [blame] | 145 | enum class Dimensionality |
| 146 | { |
| 147 | NotSpecified = 0, |
| 148 | Specified = 1, |
| 149 | Scalar = 2 |
| 150 | }; |
| 151 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 152 | /// |
| 153 | /// The padding method modifies the output of pooling layers. |
| 154 | /// In both supported methods, the values are ignored (they are |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 155 | /// not even zeroes, which would make a difference for max pooling |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 156 | /// a tensor with negative values). The difference between |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 157 | /// IgnoreValue and Exclude is that the former counts the padding |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 158 | /// fields in the divisor of Average and L2 pooling, while |
| 159 | /// Exclude does not. |
| 160 | /// |
| 161 | enum class PaddingMethod |
| 162 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 163 | /// The padding fields count, but are ignored |
David Beck | dcb751f | 2018-10-03 11:42:42 +0100 | [diff] [blame] | 164 | IgnoreValue = 0, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 165 | /// The padding fields don't count and are ignored |
David Beck | dcb751f | 2018-10-03 11:42:42 +0100 | [diff] [blame] | 166 | Exclude = 1 |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 167 | }; |
| 168 | |
Matthew Sloyan | 2e5d0b2 | 2021-10-21 14:05:31 +0100 | [diff] [blame^] | 169 | /// |
| 170 | /// The padding mode controls whether the padding should be filled with constant values (Constant), or |
| 171 | /// reflect the input, either including the border values (Symmetric) or not (Reflect). |
| 172 | /// |
| 173 | enum class PaddingMode |
| 174 | { |
| 175 | Constant = 0, |
| 176 | Reflect = 1, |
| 177 | Symmetric = 2 |
| 178 | }; |
| 179 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 180 | enum class NormalizationAlgorithmChannel |
| 181 | { |
| 182 | Across = 0, |
| 183 | Within = 1 |
| 184 | }; |
| 185 | |
| 186 | enum class NormalizationAlgorithmMethod |
| 187 | { |
David Beck | dcb751f | 2018-10-03 11:42:42 +0100 | [diff] [blame] | 188 | /// Krichevsky 2012: Local Brightness Normalization |
| 189 | LocalBrightness = 0, |
| 190 | /// Jarret 2009: Local Contrast Normalization |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 191 | LocalContrast = 1 |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 192 | }; |
| 193 | |
| 194 | enum class OutputShapeRounding |
| 195 | { |
| 196 | Floor = 0, |
| 197 | Ceiling = 1 |
| 198 | }; |
| 199 | |
Teresa Charlin | cdc0149 | 2020-06-09 18:00:20 +0100 | [diff] [blame] | 200 | /// |
| 201 | /// The ShapeInferenceMethod modify how the output shapes are treated. |
| 202 | /// When ValidateOnly is selected, the output shapes are inferred from the input parameters of the layer |
| 203 | /// and any mismatch is reported. |
| 204 | /// When InferAndValidate is selected 2 actions must be performed: (1)infer output shape from inputs and (2)validate the |
| 205 | /// shapes as in ValidateOnly. This option has been added to work with tensors which rank or dimension sizes are not |
| 206 | /// specified explicitly, however this information can be calculated from the inputs. |
| 207 | /// |
| 208 | enum class ShapeInferenceMethod |
| 209 | { |
| 210 | /// Validate all output shapes |
| 211 | ValidateOnly = 0, |
| 212 | /// Infer missing output shapes and validate all output shapes |
| 213 | InferAndValidate = 1 |
| 214 | }; |
| 215 | |
Francis Murtagh | 73d3e2e | 2021-04-29 14:23:04 +0100 | [diff] [blame] | 216 | /// Define the Memory Source to reduce copies |
| 217 | enum class MemorySource : uint32_t |
| 218 | { |
| 219 | Undefined = 0, |
| 220 | Malloc = 1, |
| 221 | DmaBuf = 2, |
| 222 | DmaBufProtected = 4 |
| 223 | }; |
| 224 | |
Sadik Armagan | 932cf3f | 2021-09-15 09:22:11 +0100 | [diff] [blame] | 225 | enum class MemBlockStrategyType |
| 226 | { |
Francis Murtagh | ca49a24 | 2021-09-28 15:30:31 +0100 | [diff] [blame] | 227 | // MemBlocks can be packed on the Y axis only, overlap allowed on X axis. |
Sadik Armagan | 932cf3f | 2021-09-15 09:22:11 +0100 | [diff] [blame] | 228 | // In other words MemBlocks with overlapping lifetimes cannot use the same MemBin, |
| 229 | // equivalent to blob or pooling memory management. |
| 230 | SingleAxisPacking = 0, |
| 231 | |
Francis Murtagh | ca49a24 | 2021-09-28 15:30:31 +0100 | [diff] [blame] | 232 | // MemBlocks can be packed on either Y or X axis but cannot overlap on both. |
Sadik Armagan | 932cf3f | 2021-09-15 09:22:11 +0100 | [diff] [blame] | 233 | // In other words MemBlocks with overlapping lifetimes can use the same MemBin, |
| 234 | // equivalent to offset or slab memory management. |
| 235 | MultiAxisPacking = 1 |
| 236 | }; |
| 237 | |
David Beck | 9efb57d | 2018-11-05 13:40:33 +0000 | [diff] [blame] | 238 | /// Each backend should implement an IBackend. |
| 239 | class IBackend |
| 240 | { |
| 241 | protected: |
| 242 | IBackend() {} |
| 243 | virtual ~IBackend() {} |
| 244 | |
| 245 | public: |
| 246 | virtual const BackendId& GetId() const = 0; |
| 247 | }; |
| 248 | |
| 249 | using IBackendSharedPtr = std::shared_ptr<IBackend>; |
| 250 | using IBackendUniquePtr = std::unique_ptr<IBackend, void(*)(IBackend* backend)>; |
| 251 | |
Sadik Armagan | f0a6dec | 2021-03-25 07:46:55 +0000 | [diff] [blame] | 252 | /// BackendCapability class |
| 253 | enum class BackendCapability : uint32_t |
| 254 | { |
| 255 | /// Constant weights can be accessed through the descriptors, |
| 256 | /// On the other hand, non-const weights can be accessed through inputs. |
| 257 | NonConstWeights, |
| 258 | |
Sadik Armagan | aede8ca | 2021-03-31 16:12:13 +0100 | [diff] [blame] | 259 | /// Asynchronous Execution. |
| 260 | AsyncExecution, |
| 261 | |
Sadik Armagan | f0a6dec | 2021-03-25 07:46:55 +0000 | [diff] [blame] | 262 | // add new enum values here |
| 263 | }; |
| 264 | |
David Beck | dcb751f | 2018-10-03 11:42:42 +0100 | [diff] [blame] | 265 | /// Device specific knowledge to be passed to the optimizer. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 266 | class IDeviceSpec |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 267 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 268 | protected: |
Matteo Martincigh | 9c5d33a | 2019-02-07 17:52:41 +0000 | [diff] [blame] | 269 | IDeviceSpec() {} |
| 270 | virtual ~IDeviceSpec() {} |
Narumol Prangnawarat | 8710676 | 2019-05-03 15:54:39 +0100 | [diff] [blame] | 271 | public: |
| 272 | virtual const BackendIdSet& GetSupportedBackends() const = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 273 | }; |
| 274 | |
| 275 | /// Type of identifiers for bindable layers (inputs, outputs). |
| 276 | using LayerBindingId = int; |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 277 | using ImportedInputId = unsigned int; |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 278 | using ImportedOutputId = unsigned int; |
| 279 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 280 | |
| 281 | class PermutationVector |
| 282 | { |
| 283 | public: |
| 284 | using ValueType = unsigned int; |
| 285 | using SizeType = unsigned int; |
| 286 | using ArrayType = std::array<ValueType, MaxNumOfTensorDimensions>; |
| 287 | using ConstIterator = typename ArrayType::const_iterator; |
| 288 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 289 | /// @param dimMappings - Indicates how to translate tensor elements from a given source into the target destination, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 290 | /// when source and target potentially have different memory layouts. |
| 291 | /// |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 292 | /// E.g. For a 4-d tensor laid out in a memory with the format (Batch Element, Height, Width, Channels), |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 293 | /// which is to be passed as an input to ArmNN, each source dimension is mapped to the corresponding |
| 294 | /// ArmNN dimension. The Batch dimension remains the same (0 -> 0). The source Height dimension is mapped |
| 295 | /// to the location of the ArmNN Height dimension (1 -> 2). Similar arguments are made for the Width and |
| 296 | /// Channels (2 -> 3 and 3 -> 1). This will lead to @ref m_DimMappings pointing to the following array: |
| 297 | /// [ 0, 2, 3, 1 ]. |
| 298 | /// |
| 299 | /// Note that the mapping should be reversed if considering the case of ArmNN 4-d outputs (Batch Element, |
| 300 | /// Channels, Height, Width) being written to a destination with the format mentioned above. We now have |
| 301 | /// 0 -> 0, 2 -> 1, 3 -> 2, 1 -> 3, which, when reordered, lead to the following @ref m_DimMappings contents: |
| 302 | /// [ 0, 3, 1, 2 ]. |
| 303 | /// |
| 304 | PermutationVector(const ValueType *dimMappings, SizeType numDimMappings); |
| 305 | |
| 306 | PermutationVector(std::initializer_list<ValueType> dimMappings); |
| 307 | |
| 308 | ValueType operator[](SizeType i) const { return m_DimMappings.at(i); } |
| 309 | |
| 310 | SizeType GetSize() const { return m_NumDimMappings; } |
| 311 | |
| 312 | ConstIterator begin() const { return m_DimMappings.begin(); } |
Colm Donelan | 41e764c | 2021-05-27 16:43:25 +0100 | [diff] [blame] | 313 | /** |
| 314 | * |
| 315 | * @return pointer one past the end of the number of mapping not the length of m_DimMappings. |
| 316 | */ |
| 317 | ConstIterator end() const { return m_DimMappings.begin() + m_NumDimMappings; } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 318 | |
| 319 | bool IsEqual(const PermutationVector& other) const |
| 320 | { |
Matthew Jackson | dba634f | 2019-08-15 15:14:18 +0100 | [diff] [blame] | 321 | if (m_NumDimMappings != other.m_NumDimMappings) return false; |
| 322 | for (unsigned int i = 0; i < m_NumDimMappings; ++i) |
| 323 | { |
| 324 | if (m_DimMappings[i] != other.m_DimMappings[i]) return false; |
| 325 | } |
| 326 | return true; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | bool IsInverse(const PermutationVector& other) const |
| 330 | { |
| 331 | bool isInverse = (GetSize() == other.GetSize()); |
| 332 | for (SizeType i = 0; isInverse && (i < GetSize()); ++i) |
| 333 | { |
| 334 | isInverse = (m_DimMappings[other.m_DimMappings[i]] == i); |
| 335 | } |
| 336 | return isInverse; |
| 337 | } |
| 338 | |
| 339 | private: |
| 340 | ArrayType m_DimMappings; |
| 341 | /// Number of valid entries in @ref m_DimMappings |
| 342 | SizeType m_NumDimMappings; |
| 343 | }; |
| 344 | |
janeil01 | 3fec1ea | 2019-11-07 09:47:20 +0000 | [diff] [blame] | 345 | namespace profiling { class ProfilingGuid; } |
| 346 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 347 | /// Define LayerGuid type. |
janeil01 | 3fec1ea | 2019-11-07 09:47:20 +0000 | [diff] [blame] | 348 | using LayerGuid = profiling::ProfilingGuid; |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 349 | |
Nattapat Chaimanowong | 6e94820 | 2019-03-22 14:01:46 +0000 | [diff] [blame] | 350 | class ITensorHandle; |
| 351 | |
Nattapat Chaimanowong | 317cae5 | 2019-03-28 10:29:12 +0000 | [diff] [blame] | 352 | /// Define the type of callback for the Debug layer to call |
| 353 | /// @param guid - guid of layer connected to the input of the Debug layer |
| 354 | /// @param slotIndex - index of the output slot connected to the input of the Debug layer |
| 355 | /// @param tensorHandle - TensorHandle for the input tensor to the Debug layer |
| 356 | using DebugCallbackFunction = std::function<void(LayerGuid guid, unsigned int slotIndex, ITensorHandle* tensorHandle)>; |
Nattapat Chaimanowong | 6e94820 | 2019-03-22 14:01:46 +0000 | [diff] [blame] | 357 | |
Keith Davis | e813d67 | 2021-04-22 10:10:34 +0100 | [diff] [blame] | 358 | /// Define a timer and associated inference ID for recording execution times |
| 359 | using HighResolutionClock = std::chrono::high_resolution_clock::time_point; |
| 360 | using InferenceTimingPair = std::pair<HighResolutionClock, HighResolutionClock>; |
janeil01 | c4946c7 | 2019-11-07 09:32:28 +0000 | [diff] [blame] | 361 | |
janeil01 | c4946c7 | 2019-11-07 09:32:28 +0000 | [diff] [blame] | 362 | |
Finn Williams | b454c5c | 2021-02-09 15:56:23 +0000 | [diff] [blame] | 363 | /// This list uses X macro technique. |
| 364 | /// See https://en.wikipedia.org/wiki/X_Macro for more info |
| 365 | #define LIST_OF_LAYER_TYPE \ |
| 366 | X(Activation) \ |
| 367 | X(Addition) \ |
| 368 | X(ArgMinMax) \ |
| 369 | X(BatchNormalization) \ |
Keith Davis | 3ae3f97 | 2021-05-21 16:33:48 +0100 | [diff] [blame] | 370 | X(BatchToSpaceNd) \ |
Finn Williams | b454c5c | 2021-02-09 15:56:23 +0000 | [diff] [blame] | 371 | X(Comparison) \ |
| 372 | X(Concat) \ |
| 373 | X(Constant) \ |
| 374 | X(ConvertBf16ToFp32) \ |
| 375 | X(ConvertFp16ToFp32) \ |
| 376 | X(ConvertFp32ToBf16) \ |
| 377 | X(ConvertFp32ToFp16) \ |
| 378 | X(Convolution2d) \ |
| 379 | X(Debug) \ |
| 380 | X(DepthToSpace) \ |
| 381 | X(DepthwiseConvolution2d) \ |
| 382 | X(Dequantize) \ |
| 383 | X(DetectionPostProcess) \ |
| 384 | X(Division) \ |
| 385 | X(ElementwiseUnary) \ |
| 386 | X(FakeQuantization) \ |
| 387 | X(Fill) \ |
| 388 | X(Floor) \ |
| 389 | X(FullyConnected) \ |
| 390 | X(Gather) \ |
| 391 | X(Input) \ |
| 392 | X(InstanceNormalization) \ |
| 393 | X(L2Normalization) \ |
| 394 | X(LogicalBinary) \ |
| 395 | X(LogSoftmax) \ |
| 396 | X(Lstm) \ |
| 397 | X(QLstm) \ |
| 398 | X(Map) \ |
| 399 | X(Maximum) \ |
| 400 | X(Mean) \ |
| 401 | X(MemCopy) \ |
| 402 | X(MemImport) \ |
| 403 | X(Merge) \ |
| 404 | X(Minimum) \ |
| 405 | X(Multiplication) \ |
| 406 | X(Normalization) \ |
| 407 | X(Output) \ |
| 408 | X(Pad) \ |
| 409 | X(Permute) \ |
| 410 | X(Pooling2d) \ |
| 411 | X(PreCompiled) \ |
| 412 | X(Prelu) \ |
| 413 | X(Quantize) \ |
| 414 | X(QuantizedLstm) \ |
| 415 | X(Reshape) \ |
| 416 | X(Rank) \ |
| 417 | X(Resize) \ |
| 418 | X(Reduce) \ |
| 419 | X(Slice) \ |
| 420 | X(Softmax) \ |
| 421 | X(SpaceToBatchNd) \ |
| 422 | X(SpaceToDepth) \ |
| 423 | X(Splitter) \ |
| 424 | X(Stack) \ |
| 425 | X(StandIn) \ |
| 426 | X(StridedSlice) \ |
| 427 | X(Subtraction) \ |
| 428 | X(Switch) \ |
| 429 | X(Transpose) \ |
| 430 | X(TransposeConvolution2d) \ |
mathad01 | b392e98 | 2021-04-07 12:07:30 +0100 | [diff] [blame] | 431 | X(Unmap) \ |
Narumol Prangnawarat | 8ed39ae | 2021-07-15 16:16:25 +0100 | [diff] [blame] | 432 | X(Cast) \ |
| 433 | X(Shape) \ |
| 434 | X(UnidirectionalSequenceLstm) \ |
Simon Obute | 51f6777 | 2021-09-03 15:50:13 +0100 | [diff] [blame] | 435 | X(ChannelShuffle) \ |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 436 | X(Convolution3d) \ |
| 437 | |
Narumol Prangnawarat | 8ed39ae | 2021-07-15 16:16:25 +0100 | [diff] [blame] | 438 | // New layers should be added at last to minimize instability. |
Keith Davis | 3ae3f97 | 2021-05-21 16:33:48 +0100 | [diff] [blame] | 439 | |
Finn Williams | b454c5c | 2021-02-09 15:56:23 +0000 | [diff] [blame] | 440 | /// When adding a new layer, adapt also the LastLayer enum value in the |
| 441 | /// enum class LayerType below |
| 442 | enum class LayerType |
| 443 | { |
| 444 | #define X(name) name, |
| 445 | LIST_OF_LAYER_TYPE |
| 446 | #undef X |
| 447 | FirstLayer = Activation, |
Narumol Prangnawarat | 8ed39ae | 2021-07-15 16:16:25 +0100 | [diff] [blame] | 448 | LastLayer = UnidirectionalSequenceLstm |
Finn Williams | b454c5c | 2021-02-09 15:56:23 +0000 | [diff] [blame] | 449 | }; |
| 450 | |
| 451 | const char* GetLayerTypeAsCString(LayerType type); |
| 452 | |
David Beck | 9df2d95 | 2018-10-10 15:11:44 +0100 | [diff] [blame] | 453 | } // namespace armnn |