telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 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 | |
| 6 | #include "NeonLayerSupport.hpp" |
David Beck | 3e9e115 | 2018-10-17 14:17:50 +0100 | [diff] [blame] | 7 | #include "NeonBackendId.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 9 | #include <armnn/Descriptors.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 10 | #include <InternalTypes.hpp> |
| 11 | #include <LayerSupportCommon.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 12 | #include <armnn/Tensor.hpp> |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 13 | #include <armnn/Types.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 14 | |
David Beck | 111b5d9 | 2018-11-12 14:59:37 +0000 | [diff] [blame] | 15 | #include <backendsCommon/BackendRegistry.hpp> |
David Beck | 3e9e115 | 2018-10-17 14:17:50 +0100 | [diff] [blame] | 16 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 17 | #include <boost/core/ignore_unused.hpp> |
| 18 | |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 19 | #if defined(ARMCOMPUTENEON_ENABLED) |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 20 | #include <aclCommon/ArmComputeUtils.hpp> |
Matthew Bentham | 955258d | 2018-12-10 10:48:52 +0000 | [diff] [blame] | 21 | #include "workloads/NeonAdditionWorkload.hpp" |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 22 | #include "workloads/NeonActivationWorkload.hpp" |
Matthew Bentham | c48ac8c | 2018-12-12 16:15:59 +0000 | [diff] [blame] | 23 | #include "workloads/NeonBatchNormalizationWorkload.hpp" |
Nattapat Chaimanowong | 974b65f | 2018-10-15 15:07:34 +0100 | [diff] [blame] | 24 | #include "workloads/NeonConvolution2dWorkload.hpp" |
Nattapat Chaimanowong | 7714088 | 2018-10-17 11:12:19 +0100 | [diff] [blame] | 25 | #include "workloads/NeonDepthwiseConvolutionWorkload.hpp" |
Narumol Prangnawarat | 01961a7 | 2019-05-30 16:47:12 +0100 | [diff] [blame] | 26 | #include "workloads/NeonDequantizeWorkload.hpp" |
kevmay01 | eed8592 | 2019-01-28 08:37:25 +0000 | [diff] [blame] | 27 | #include "workloads/NeonGreaterWorkload.hpp" |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 28 | #include "workloads/NeonL2NormalizationFloatWorkload.hpp" |
Jan Eilers | ad5293a | 2019-07-08 09:57:55 +0100 | [diff] [blame] | 29 | #include "workloads/NeonLstmFloatWorkload.hpp" |
Nattapat Chaimanowong | 4e6597a | 2018-12-20 14:14:06 +0000 | [diff] [blame] | 30 | #include "workloads/NeonMaximumWorkload.hpp" |
Matthew Bentham | fd89996 | 2018-12-31 15:49:42 +0000 | [diff] [blame] | 31 | #include "workloads/NeonMeanWorkload.hpp" |
Jim Flynn | 39d487d | 2019-05-17 15:44:36 +0100 | [diff] [blame] | 32 | #include "workloads/NeonConcatWorkload.hpp" |
Conor Kennedy | 54b2169 | 2019-01-09 07:57:38 +0000 | [diff] [blame] | 33 | #include "workloads/NeonMinimumWorkload.hpp" |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 34 | #include "workloads/NeonMultiplicationWorkload.hpp" |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 35 | #include "workloads/NeonNormalizationFloatWorkload.hpp" |
| 36 | #include "workloads/NeonFullyConnectedWorkload.hpp" |
Éanna Ó Catháin | 1205574 | 2019-01-25 10:01:40 +0000 | [diff] [blame] | 37 | #include "workloads/NeonPadWorkload.hpp" |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 38 | #include "workloads/NeonPermuteWorkload.hpp" |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 39 | #include "workloads/NeonPooling2dWorkload.hpp" |
Nikhil Raj | 9b46148 | 2019-07-03 15:58:31 +0100 | [diff] [blame] | 40 | #include "workloads/NeonPreluWorkload.hpp" |
Sadik Armagan | fabc289 | 2019-05-31 09:05:11 +0100 | [diff] [blame] | 41 | #include "workloads/NeonQuantizeWorkload.hpp" |
Francis Murtagh | 4fc3c48 | 2019-08-02 13:20:54 +0100 | [diff] [blame] | 42 | #include "workloads/NeonQuantizedLstmWorkload.hpp" |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 43 | #include "workloads/NeonResizeWorkload.hpp" |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 44 | #include "workloads/NeonSoftmaxBaseWorkload.hpp" |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 45 | #include "workloads/NeonSpaceToDepthWorkload.hpp" |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 46 | #include "workloads/NeonSplitterWorkload.hpp" |
Matthew Jackson | 87f65ea | 2019-08-01 10:01:34 +0100 | [diff] [blame] | 47 | #include "workloads/NeonStackWorkload.hpp" |
FinnWilliamsArm | 1fa1919 | 2019-08-02 17:26:31 +0100 | [diff] [blame] | 48 | #include "workloads/NeonStridedSliceWorkload.hpp" |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 49 | #include "workloads/NeonSubtractionWorkload.hpp" |
Sadik Armagan | 581742d | 2019-08-12 14:11:37 +0100 | [diff] [blame] | 50 | #include "workloads/NeonTransposeConvolution2dWorkload.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 51 | #endif |
| 52 | |
| 53 | using namespace boost; |
| 54 | |
| 55 | namespace armnn |
| 56 | { |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 57 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 58 | namespace |
arovir01 | 7ff76c5 | 2018-10-09 09:40:58 +0100 | [diff] [blame] | 59 | { |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 60 | |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 61 | bool IsNeonBackendSupported(Optional<std::string&> reasonIfUnsupported) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 62 | { |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 63 | #if defined(ARMCOMPUTENEON_ENABLED) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 64 | return true; |
| 65 | #else |
Derek Lamberti | 0790dce | 2019-04-15 18:37:35 +0100 | [diff] [blame] | 66 | SetValueChecked(reasonIfUnsupported, "The armnn library has been built without NEON support"); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 67 | return false; |
| 68 | #endif |
| 69 | } |
| 70 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 71 | template<typename FloatFunc, typename Uint8Func, typename ... Params> |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 72 | bool IsSupportedForDataTypeNeon(Optional<std::string&> reasonIfUnsupported, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 73 | DataType dataType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 74 | FloatFunc floatFuncPtr, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 75 | Uint8Func uint8FuncPtr, |
| 76 | Params&&... params) |
| 77 | { |
| 78 | return IsNeonBackendSupported(reasonIfUnsupported) && |
| 79 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 80 | dataType, |
| 81 | floatFuncPtr, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 82 | floatFuncPtr, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 83 | uint8FuncPtr, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 84 | &FalseFunc<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 85 | &FalseFunc<>, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 86 | std::forward<Params>(params)...); |
| 87 | } |
| 88 | |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 89 | #if defined(ARMCOMPUTENEON_ENABLED) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 90 | template<class FuncType, class... Args> |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 91 | inline bool IsWorkloadSupported(FuncType& func, Optional<std::string&> reasonIfUnsupported, Args&&... args) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 92 | { |
| 93 | arm_compute::Status aclStatus = func(std::forward<Args>(args)...); |
| 94 | const bool supported = (aclStatus.error_code() == arm_compute::ErrorCode::OK); |
| 95 | if (!supported && reasonIfUnsupported) |
| 96 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 97 | reasonIfUnsupported.value() = aclStatus.error_description(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 98 | } |
| 99 | return supported; |
| 100 | } |
| 101 | |
| 102 | #define FORWARD_WORKLOAD_VALIDATE_FUNC(func, reasonIfUnsupported, ...) \ |
| 103 | return IsWorkloadSupported(func, reasonIfUnsupported, __VA_ARGS__); |
| 104 | #else |
| 105 | #define FORWARD_WORKLOAD_VALIDATE_FUNC(func, reasonIfUnsupported, ...) \ |
| 106 | return IsNeonBackendSupported(reasonIfUnsupported); |
| 107 | #endif |
| 108 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 109 | } // anonymous namespace |
| 110 | |
| 111 | bool NeonLayerSupport::IsActivationSupported(const TensorInfo& input, |
| 112 | const TensorInfo& output, |
| 113 | const ActivationDescriptor& descriptor, |
| 114 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 115 | { |
| 116 | ignore_unused(descriptor); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 117 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonActivationWorkloadValidate, |
| 118 | reasonIfUnsupported, |
| 119 | input, |
| 120 | output, |
| 121 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 124 | bool NeonLayerSupport::IsAdditionSupported(const TensorInfo& input0, |
| 125 | const TensorInfo& input1, |
| 126 | const TensorInfo& output, |
| 127 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 128 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 129 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonAdditionWorkloadValidate, |
| 130 | reasonIfUnsupported, |
| 131 | input0, |
| 132 | input1, |
| 133 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 134 | } |
| 135 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 136 | bool NeonLayerSupport::IsBatchNormalizationSupported(const TensorInfo& input, |
| 137 | const TensorInfo& output, |
| 138 | const TensorInfo& mean, |
| 139 | const TensorInfo& var, |
| 140 | const TensorInfo& beta, |
| 141 | const TensorInfo& gamma, |
| 142 | const BatchNormalizationDescriptor& descriptor, |
| 143 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 144 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 145 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonBatchNormalizationValidate, |
| 146 | reasonIfUnsupported, |
| 147 | input, |
| 148 | output, |
| 149 | mean, |
| 150 | var, |
| 151 | beta, |
| 152 | gamma, |
| 153 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 154 | } |
| 155 | |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 156 | bool NeonLayerSupport::IsConcatSupported(const std::vector<const TensorInfo*> inputs, |
| 157 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 158 | const ConcatDescriptor& descriptor, |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 159 | Optional<std::string&> reasonIfUnsupported) const |
| 160 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 161 | if (descriptor.GetNumDimensions() <= descriptor.GetConcatAxis()) |
| 162 | { |
| 163 | SetValueChecked(reasonIfUnsupported, "Neon Concat: Concat axis > Number of dimensions."); |
| 164 | return false; |
| 165 | } |
| 166 | |
| 167 | unsigned int concatInnerAxis = (descriptor.GetNumDimensions() - descriptor.GetConcatAxis()) - 1; |
| 168 | if(concatInnerAxis < 3) // Width, height, or channels |
| 169 | { |
| 170 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonConcatWorkloadValidate, |
| 171 | reasonIfUnsupported, |
| 172 | inputs, |
| 173 | output, |
| 174 | descriptor); |
| 175 | } |
| 176 | else if (concatInnerAxis == 3) |
| 177 | { |
| 178 | for (auto& input : inputs) |
| 179 | { |
| 180 | if (input && !output.IsTypeSpaceMatch(*input)) // Cannot use sub-tensors if the types are not same space |
| 181 | { |
| 182 | SetValueChecked(reasonIfUnsupported, "Neon Concat: Types and quantization parameters must match."); |
| 183 | return false; |
| 184 | } |
| 185 | } |
| 186 | return true; // Sub-tensors support concat along batch |
| 187 | } |
| 188 | else // > 4 dimensions not supported. |
| 189 | { |
| 190 | SetValueChecked(reasonIfUnsupported, "Neon Concat: Maximum of 4 dimensions supported."); |
| 191 | return false; |
| 192 | } |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 193 | } |
| 194 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 195 | bool NeonLayerSupport::IsConstantSupported(const TensorInfo& output, |
| 196 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 197 | { |
| 198 | return IsSupportedForDataTypeNeon(reasonIfUnsupported, |
| 199 | output.GetDataType(), |
| 200 | &TrueFunc<>, |
| 201 | &TrueFunc<>); |
| 202 | } |
| 203 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 204 | bool NeonLayerSupport::IsConvertFp16ToFp32Supported(const TensorInfo& input, |
| 205 | const TensorInfo& output, |
| 206 | Optional<std::string&> reasonIfUnsupported) const |
| 207 | { |
| 208 | ignore_unused(input); |
| 209 | ignore_unused(output); |
| 210 | ignore_unused(reasonIfUnsupported); |
| 211 | return true; |
| 212 | } |
| 213 | |
| 214 | bool NeonLayerSupport::IsConvertFp32ToFp16Supported(const TensorInfo& input, |
| 215 | const TensorInfo& output, |
| 216 | Optional<std::string&> reasonIfUnsupported) const |
| 217 | { |
| 218 | ignore_unused(input); |
| 219 | ignore_unused(output); |
| 220 | ignore_unused(reasonIfUnsupported); |
| 221 | return true; |
| 222 | } |
| 223 | |
| 224 | bool NeonLayerSupport::IsConvolution2dSupported(const TensorInfo& input, |
| 225 | const TensorInfo& output, |
| 226 | const Convolution2dDescriptor& descriptor, |
| 227 | const TensorInfo& weights, |
| 228 | const Optional<TensorInfo>& biases, |
| 229 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 230 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 231 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonConvolution2dWorkloadValidate, |
| 232 | reasonIfUnsupported, |
| 233 | input, |
| 234 | output, |
| 235 | descriptor, |
| 236 | weights, |
| 237 | biases); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 238 | } |
| 239 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 240 | bool NeonLayerSupport::IsDepthwiseConvolutionSupported(const TensorInfo& input, |
| 241 | const TensorInfo& output, |
| 242 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 243 | const TensorInfo& weights, |
| 244 | const Optional<TensorInfo>& biases, |
| 245 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 246 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 247 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonDepthwiseConvolutionWorkloadValidate, |
| 248 | reasonIfUnsupported, |
| 249 | input, |
| 250 | output, |
| 251 | descriptor, |
| 252 | weights, |
| 253 | biases); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 254 | } |
| 255 | |
Narumol Prangnawarat | 01961a7 | 2019-05-30 16:47:12 +0100 | [diff] [blame] | 256 | bool NeonLayerSupport::IsDequantizeSupported(const TensorInfo& input, |
| 257 | const TensorInfo& output, |
| 258 | Optional<std::string&> reasonIfUnsupported) const |
| 259 | { |
| 260 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonDequantizeWorkloadValidate, |
| 261 | reasonIfUnsupported, |
| 262 | input, |
| 263 | output); |
| 264 | } |
| 265 | |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 266 | bool NeonLayerSupport::IsDilatedDepthwiseConvolutionSupported(const TensorInfo& input, |
| 267 | const TensorInfo& output, |
| 268 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 269 | const TensorInfo& weights, |
| 270 | const Optional<TensorInfo>& biases, |
| 271 | Optional<std::string&> reasonIfUnsupported) const |
| 272 | { |
| 273 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonDepthwiseConvolutionWorkloadValidate, |
| 274 | reasonIfUnsupported, |
| 275 | input, |
| 276 | output, |
| 277 | descriptor, |
| 278 | weights, |
| 279 | biases); |
| 280 | } |
| 281 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 282 | bool NeonLayerSupport::IsFloorSupported(const TensorInfo& input, |
| 283 | const TensorInfo& output, |
| 284 | Optional<std::string&> reasonIfUnsupported) const |
| 285 | { |
| 286 | ignore_unused(output); |
| 287 | return IsNeonBackendSupported(reasonIfUnsupported) && |
| 288 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 289 | input.GetDataType(), |
| 290 | &FalseFuncF16<>, |
| 291 | &TrueFunc<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 292 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 293 | &FalseFuncI32<>, |
| 294 | &FalseFuncU8<>); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | bool NeonLayerSupport::IsFullyConnectedSupported(const TensorInfo& input, |
| 298 | const TensorInfo& output, |
| 299 | const TensorInfo& weights, |
| 300 | const TensorInfo& biases, |
| 301 | const FullyConnectedDescriptor& descriptor, |
| 302 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 303 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 304 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonFullyConnectedWorkloadValidate, |
| 305 | reasonIfUnsupported, |
| 306 | input, |
| 307 | output, |
| 308 | weights, |
| 309 | biases, |
| 310 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 311 | } |
| 312 | |
kevmay01 | eed8592 | 2019-01-28 08:37:25 +0000 | [diff] [blame] | 313 | bool NeonLayerSupport::IsGreaterSupported(const armnn::TensorInfo& input0, |
| 314 | const armnn::TensorInfo& input1, |
| 315 | const armnn::TensorInfo& output, |
| 316 | armnn::Optional<std::string&> reasonIfUnsupported) const |
| 317 | { |
| 318 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonGreaterWorkloadValidate, |
| 319 | reasonIfUnsupported, |
| 320 | input0, |
| 321 | input1, |
| 322 | output); |
| 323 | } |
| 324 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 325 | bool NeonLayerSupport::IsInputSupported(const TensorInfo& input, |
| 326 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 327 | { |
Francis Murtagh | b3fc252 | 2019-08-09 13:20:50 +0100 | [diff] [blame] | 328 | return IsNeonBackendSupported(reasonIfUnsupported); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 329 | } |
| 330 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 331 | bool NeonLayerSupport::IsL2NormalizationSupported(const TensorInfo& input, |
| 332 | const TensorInfo& output, |
| 333 | const L2NormalizationDescriptor& descriptor, |
| 334 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 335 | { |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 336 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonL2NormalizationWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 337 | } |
| 338 | |
Jan Eilers | ad5293a | 2019-07-08 09:57:55 +0100 | [diff] [blame] | 339 | bool NeonLayerSupport::IsLstmSupported(const TensorInfo& input, |
| 340 | const TensorInfo& outputStateIn, |
| 341 | const TensorInfo& cellStateIn, |
| 342 | const TensorInfo& scratchBuffer, |
| 343 | const TensorInfo& outputStateOut, |
| 344 | const TensorInfo& cellStateOut, |
| 345 | const TensorInfo& output, |
| 346 | const LstmDescriptor& descriptor, |
| 347 | const LstmInputParamsInfo& paramsInfo, |
| 348 | Optional<std::string&> reasonIfUnsupported) const |
| 349 | { |
| 350 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonLstmFloatWorkloadValidate, |
| 351 | reasonIfUnsupported, |
| 352 | input, |
| 353 | outputStateIn, |
| 354 | cellStateIn, |
| 355 | scratchBuffer, |
| 356 | outputStateOut, |
| 357 | cellStateOut, |
| 358 | output, |
| 359 | descriptor, |
| 360 | paramsInfo); |
| 361 | } |
| 362 | |
Nattapat Chaimanowong | 4e6597a | 2018-12-20 14:14:06 +0000 | [diff] [blame] | 363 | bool NeonLayerSupport::IsMaximumSupported(const TensorInfo& input0, |
| 364 | const TensorInfo& input1, |
| 365 | const TensorInfo& output, |
| 366 | Optional<std::string&> reasonIfUnsupported) const |
| 367 | { |
| 368 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMaximumWorkloadValidate, |
| 369 | reasonIfUnsupported, |
| 370 | input0, |
| 371 | input1, |
| 372 | output); |
| 373 | } |
| 374 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 375 | bool NeonLayerSupport::IsMeanSupported(const TensorInfo& input, |
| 376 | const TensorInfo& output, |
| 377 | const MeanDescriptor& descriptor, |
| 378 | Optional<std::string&> reasonIfUnsupported) const |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 379 | { |
Matthew Bentham | fd89996 | 2018-12-31 15:49:42 +0000 | [diff] [blame] | 380 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMeanWorkloadValidate, |
| 381 | reasonIfUnsupported, |
| 382 | input, |
| 383 | output, |
| 384 | descriptor); |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 385 | } |
| 386 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 387 | bool NeonLayerSupport::IsMergerSupported(const std::vector<const TensorInfo*> inputs, |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 388 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 389 | const MergerDescriptor& descriptor, |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 390 | Optional<std::string&> reasonIfUnsupported) const |
| 391 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 392 | return IsConcatSupported(inputs, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 393 | } |
| 394 | |
Conor Kennedy | 54b2169 | 2019-01-09 07:57:38 +0000 | [diff] [blame] | 395 | bool NeonLayerSupport::IsMinimumSupported(const TensorInfo& input0, |
| 396 | const TensorInfo& input1, |
| 397 | const TensorInfo& output, |
| 398 | Optional<std::string&> reasonIfUnsupported) const |
| 399 | { |
| 400 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMinimumWorkloadValidate, |
| 401 | reasonIfUnsupported, |
| 402 | input0, |
| 403 | input1, |
| 404 | output); |
| 405 | } |
| 406 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 407 | bool NeonLayerSupport::IsMultiplicationSupported(const TensorInfo& input0, |
| 408 | const TensorInfo& input1, |
| 409 | const TensorInfo& output, |
| 410 | Optional<std::string&> reasonIfUnsupported) const |
| 411 | { |
| 412 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMultiplicationWorkloadValidate, |
| 413 | reasonIfUnsupported, |
| 414 | input0, |
| 415 | input1, |
| 416 | output); |
| 417 | } |
| 418 | |
| 419 | bool NeonLayerSupport::IsNormalizationSupported(const TensorInfo& input, |
| 420 | const TensorInfo& output, |
| 421 | const NormalizationDescriptor& descriptor, |
| 422 | Optional<std::string&> reasonIfUnsupported) const |
| 423 | { |
| 424 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonNormalizationWorkloadValidate, |
| 425 | reasonIfUnsupported, |
| 426 | input, |
| 427 | output, |
| 428 | descriptor); |
| 429 | } |
| 430 | |
| 431 | bool NeonLayerSupport::IsOutputSupported(const TensorInfo& output, |
| 432 | Optional<std::string&> reasonIfUnsupported) const |
| 433 | { |
Francis Murtagh | b3fc252 | 2019-08-09 13:20:50 +0100 | [diff] [blame] | 434 | return IsNeonBackendSupported(reasonIfUnsupported); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 435 | } |
| 436 | |
Éanna Ó Catháin | 1205574 | 2019-01-25 10:01:40 +0000 | [diff] [blame] | 437 | bool NeonLayerSupport::IsPadSupported(const TensorInfo& input, |
| 438 | const TensorInfo& output, |
| 439 | const PadDescriptor& descriptor, |
| 440 | Optional<std::string&> reasonIfUnsupported) const |
| 441 | { |
| 442 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonPadWorkloadValidate, |
| 443 | reasonIfUnsupported, |
| 444 | input, |
| 445 | output, |
| 446 | descriptor); |
| 447 | } |
| 448 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 449 | bool NeonLayerSupport::IsPermuteSupported(const TensorInfo& input, |
| 450 | const TensorInfo& output, |
| 451 | const PermuteDescriptor& descriptor, |
| 452 | Optional<std::string&> reasonIfUnsupported) const |
| 453 | { |
| 454 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonPermuteWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 455 | } |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 456 | |
| 457 | bool NeonLayerSupport::IsPooling2dSupported(const TensorInfo& input, |
| 458 | const TensorInfo& output, |
| 459 | const Pooling2dDescriptor& descriptor, |
| 460 | Optional<std::string&> reasonIfUnsupported) const |
| 461 | { |
| 462 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonPooling2dWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 463 | } |
| 464 | |
Nikhil Raj | 9b46148 | 2019-07-03 15:58:31 +0100 | [diff] [blame] | 465 | bool NeonLayerSupport::IsPreluSupported(const armnn::TensorInfo &input, |
| 466 | const armnn::TensorInfo &alpha, |
| 467 | const armnn::TensorInfo &output, |
| 468 | armnn::Optional<std::string &> reasonIfUnsupported) const |
| 469 | { |
| 470 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonPreluWorkloadValidate, reasonIfUnsupported, input, alpha, output); |
| 471 | } |
| 472 | |
Sadik Armagan | fabc289 | 2019-05-31 09:05:11 +0100 | [diff] [blame] | 473 | bool NeonLayerSupport::IsQuantizeSupported(const TensorInfo& input, |
| 474 | const TensorInfo& output, |
| 475 | Optional<std::string&> reasonIfUnsupported) const |
| 476 | { |
| 477 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonQuantizeWorkloadValidate, |
| 478 | reasonIfUnsupported, |
| 479 | input, |
| 480 | output); |
| 481 | } |
| 482 | |
Francis Murtagh | 4fc3c48 | 2019-08-02 13:20:54 +0100 | [diff] [blame] | 483 | bool NeonLayerSupport::IsQuantizedLstmSupported(const TensorInfo& input, |
| 484 | const TensorInfo& cellStateIn, |
| 485 | const TensorInfo& outputStateIn, |
| 486 | const TensorInfo& cellStateOut, |
| 487 | const TensorInfo& outputStateOut, |
| 488 | const QuantizedLstmInputParamsInfo& paramsInfo, |
| 489 | Optional<std::string&> reasonIfUnsupported) const |
| 490 | { |
| 491 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonQuantizedLstmWorkloadValidate, |
| 492 | reasonIfUnsupported, |
| 493 | input, |
| 494 | cellStateIn, |
| 495 | outputStateIn, |
| 496 | cellStateOut, |
| 497 | outputStateOut, |
| 498 | paramsInfo); |
| 499 | } |
| 500 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 501 | bool NeonLayerSupport::IsReshapeSupported(const TensorInfo& input, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 502 | const ReshapeDescriptor& descriptor, |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 503 | Optional<std::string&> reasonIfUnsupported) const |
| 504 | { |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 505 | ignore_unused(descriptor); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 506 | return IsSupportedForDataTypeNeon(reasonIfUnsupported, |
| 507 | input.GetDataType(), |
| 508 | &TrueFunc<>, |
| 509 | &TrueFunc<>); |
| 510 | } |
| 511 | |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 512 | bool NeonLayerSupport::IsResizeSupported(const TensorInfo& input, |
| 513 | const TensorInfo& output, |
| 514 | const ResizeDescriptor& descriptor, |
| 515 | Optional<std::string&> reasonIfUnsupported) const |
| 516 | { |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 517 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonResizeWorkloadValidate, |
| 518 | reasonIfUnsupported, |
| 519 | input, |
| 520 | output, |
| 521 | descriptor); |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 522 | } |
| 523 | |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame] | 524 | bool NeonLayerSupport::IsResizeBilinearSupported(const TensorInfo& input, |
| 525 | const TensorInfo& output, |
| 526 | Optional<std::string&> reasonIfUnsupported) const |
| 527 | { |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 528 | ResizeDescriptor descriptor; |
| 529 | descriptor.m_Method = ResizeMethod::Bilinear; |
| 530 | descriptor.m_DataLayout = DataLayout::NCHW; |
| 531 | |
| 532 | const TensorShape& outputShape = output.GetShape(); |
| 533 | descriptor.m_TargetHeight = outputShape[2]; |
| 534 | descriptor.m_TargetWidth = outputShape[3]; |
| 535 | |
| 536 | return IsResizeSupported(input, output, descriptor, reasonIfUnsupported); |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame] | 537 | } |
| 538 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 539 | bool NeonLayerSupport::IsSoftmaxSupported(const TensorInfo& input, |
| 540 | const TensorInfo& output, |
| 541 | const SoftmaxDescriptor& descriptor, |
| 542 | Optional<std::string&> reasonIfUnsupported) const |
| 543 | { |
| 544 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSoftmaxWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 545 | } |
| 546 | |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 547 | bool NeonLayerSupport::IsSpaceToDepthSupported(const TensorInfo& input, |
| 548 | const TensorInfo& output, |
| 549 | const SpaceToDepthDescriptor& descriptor, |
| 550 | Optional<std::string&> reasonIfUnsupported) const |
| 551 | { |
| 552 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSpaceToDepthWorkloadValidate, |
| 553 | reasonIfUnsupported, |
| 554 | input, |
| 555 | output, |
| 556 | descriptor); |
| 557 | } |
| 558 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 559 | bool NeonLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 560 | const ViewsDescriptor& descriptor, |
| 561 | Optional<std::string&> reasonIfUnsupported) const |
| 562 | { |
| 563 | ignore_unused(descriptor); |
| 564 | return IsSupportedForDataTypeNeon(reasonIfUnsupported, |
| 565 | input.GetDataType(), |
| 566 | &TrueFunc<>, |
| 567 | &TrueFunc<>); |
| 568 | } |
| 569 | |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 570 | bool NeonLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 571 | const std::vector<std::reference_wrapper<TensorInfo>>& outputs, |
| 572 | const ViewsDescriptor& descriptor, |
| 573 | Optional<std::string&> reasonIfUnsupported) const |
| 574 | { |
| 575 | #if defined(ARMCOMPUTENEON_ENABLED) |
| 576 | // Split along the last dimension, cannot use sub-tensors |
| 577 | // as width and height of the sub-tensors do not match |
| 578 | // the width and height of the parent tensor |
| 579 | // in case of input with more than 2D. |
| 580 | std::set<unsigned int> splitAxis = ComputeSplitAxis(descriptor, input.GetShape()); |
| 581 | if (descriptor.GetNumDimensions() > 2 && splitAxis.size() == 1 && |
| 582 | *splitAxis.begin() == descriptor.GetNumDimensions() - 1 ) |
| 583 | { |
| 584 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSplitterWorkloadValidate, |
| 585 | reasonIfUnsupported, |
| 586 | input, |
| 587 | outputs, |
| 588 | *splitAxis.begin()); |
| 589 | } |
| 590 | #endif |
| 591 | for (auto output : outputs) |
| 592 | { |
| 593 | if (!input.IsTypeSpaceMatch(output)) // Cannot use sub-tensors if the types are not same space |
| 594 | { |
| 595 | SetValueChecked(reasonIfUnsupported, "Neon Splitter: Types and quantization parameters must match."); |
| 596 | return false; |
| 597 | } |
| 598 | } |
| 599 | return true; |
| 600 | } |
| 601 | |
Matthew Jackson | 87f65ea | 2019-08-01 10:01:34 +0100 | [diff] [blame] | 602 | bool NeonLayerSupport::IsStackSupported(const std::vector<const TensorInfo*>& inputs, |
| 603 | const TensorInfo& output, |
| 604 | const StackDescriptor& descriptor, |
| 605 | Optional<std::string&> reasonIfUnsupported) const |
| 606 | { |
| 607 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonStackWorkloadValidate, |
| 608 | reasonIfUnsupported, |
| 609 | inputs, |
| 610 | output, |
| 611 | descriptor); |
| 612 | } |
| 613 | |
FinnWilliamsArm | 1fa1919 | 2019-08-02 17:26:31 +0100 | [diff] [blame] | 614 | bool NeonLayerSupport::IsStridedSliceSupported(const TensorInfo& input, |
| 615 | const TensorInfo& output, |
| 616 | const StridedSliceDescriptor& descriptor, |
| 617 | Optional<std::string&> reasonIfUnsupported) const |
| 618 | { |
| 619 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonStridedSliceWorkloadValidate, |
| 620 | reasonIfUnsupported, |
| 621 | input, |
| 622 | output, |
| 623 | descriptor); |
| 624 | } |
| 625 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 626 | bool NeonLayerSupport::IsSubtractionSupported(const TensorInfo& input0, |
| 627 | const TensorInfo& input1, |
| 628 | const TensorInfo& output, |
| 629 | Optional<std::string&> reasonIfUnsupported) const |
| 630 | { |
| 631 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSubtractionWorkloadValidate, |
| 632 | reasonIfUnsupported, |
| 633 | input0, |
| 634 | input1, |
| 635 | output); |
| 636 | } |
| 637 | |
Sadik Armagan | 581742d | 2019-08-12 14:11:37 +0100 | [diff] [blame] | 638 | bool NeonLayerSupport::IsTransposeConvolution2dSupported(const TensorInfo& input, |
| 639 | const TensorInfo& output, |
| 640 | const TransposeConvolution2dDescriptor& descriptor, |
| 641 | const TensorInfo& weights, |
| 642 | const Optional<TensorInfo>& biases, |
| 643 | Optional<std::string&> reasonIfUnsupported) const |
| 644 | { |
| 645 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonTransposeConvolution2dWorkloadValidate, |
| 646 | reasonIfUnsupported, |
| 647 | input, |
| 648 | output, |
| 649 | descriptor, |
| 650 | weights, |
| 651 | biases); |
| 652 | } |
| 653 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 654 | } // namespace armnn |