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