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> |
Derek Lamberti | c77874a | 2020-04-28 13:34:56 +0100 | [diff] [blame^] | 10 | #include <armnn/Exceptions.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 11 | #include <armnn/Tensor.hpp> |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 12 | #include <armnn/Types.hpp> |
Matteo Martincigh | c601aa6 | 2019-10-29 15:03:22 +0000 | [diff] [blame] | 13 | #include <armnn/BackendRegistry.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 14 | |
Matteo Martincigh | c601aa6 | 2019-10-29 15:03:22 +0000 | [diff] [blame] | 15 | #include <InternalTypes.hpp> |
| 16 | #include <LayerSupportCommon.hpp> |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 17 | #include <armnn/utility/IgnoreUnused.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 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> |
Aron Virginas-Tar | 710f664 | 2019-11-27 14:48:32 +0000 | [diff] [blame] | 21 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
Aron Virginas-Tar | 914e4db | 2019-09-09 13:36:45 +0100 | [diff] [blame] | 22 | #include "workloads/NeonAbsWorkload.hpp" |
Matthew Bentham | 955258d | 2018-12-10 10:48:52 +0000 | [diff] [blame] | 23 | #include "workloads/NeonAdditionWorkload.hpp" |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 24 | #include "workloads/NeonActivationWorkload.hpp" |
James Conroy | d47a064 | 2019-09-17 14:22:06 +0100 | [diff] [blame] | 25 | #include "workloads/NeonArgMinMaxWorkload.hpp" |
Matthew Bentham | c48ac8c | 2018-12-12 16:15:59 +0000 | [diff] [blame] | 26 | #include "workloads/NeonBatchNormalizationWorkload.hpp" |
Mike Kelly | 5685802 | 2020-01-27 12:14:47 +0000 | [diff] [blame] | 27 | #include "workloads/NeonBatchToSpaceNdWorkload.hpp" |
Derek Lamberti | c77874a | 2020-04-28 13:34:56 +0100 | [diff] [blame^] | 28 | #include "workloads/NeonExpWorkload.hpp" |
Teresa Charlin | cedd34f | 2020-03-30 11:17:30 +0100 | [diff] [blame] | 29 | #include "workloads/NeonComparisonWorkload.hpp" |
Mike Kelly | 0886ac4 | 2020-04-27 09:55:40 +0100 | [diff] [blame] | 30 | #include "workloads/NeonConstantWorkload.hpp" |
Nattapat Chaimanowong | 974b65f | 2018-10-15 15:07:34 +0100 | [diff] [blame] | 31 | #include "workloads/NeonConvolution2dWorkload.hpp" |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 32 | #include "workloads/NeonDepthToSpaceWorkload.hpp" |
Nattapat Chaimanowong | 7714088 | 2018-10-17 11:12:19 +0100 | [diff] [blame] | 33 | #include "workloads/NeonDepthwiseConvolutionWorkload.hpp" |
Narumol Prangnawarat | 01961a7 | 2019-05-30 16:47:12 +0100 | [diff] [blame] | 34 | #include "workloads/NeonDequantizeWorkload.hpp" |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 35 | #include "workloads/NeonInstanceNormalizationWorkload.hpp" |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 36 | #include "workloads/NeonL2NormalizationFloatWorkload.hpp" |
Jan Eilers | ad5293a | 2019-07-08 09:57:55 +0100 | [diff] [blame] | 37 | #include "workloads/NeonLstmFloatWorkload.hpp" |
Nattapat Chaimanowong | 4e6597a | 2018-12-20 14:14:06 +0000 | [diff] [blame] | 38 | #include "workloads/NeonMaximumWorkload.hpp" |
Matthew Bentham | fd89996 | 2018-12-31 15:49:42 +0000 | [diff] [blame] | 39 | #include "workloads/NeonMeanWorkload.hpp" |
Jim Flynn | 39d487d | 2019-05-17 15:44:36 +0100 | [diff] [blame] | 40 | #include "workloads/NeonConcatWorkload.hpp" |
Conor Kennedy | 54b2169 | 2019-01-09 07:57:38 +0000 | [diff] [blame] | 41 | #include "workloads/NeonMinimumWorkload.hpp" |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 42 | #include "workloads/NeonMultiplicationWorkload.hpp" |
Pablo Tello | e61f071 | 2020-01-23 10:37:17 +0000 | [diff] [blame] | 43 | #include "workloads/NeonDivisionWorkload.hpp" |
Sadik Armagan | ac47210 | 2020-03-24 09:54:36 +0000 | [diff] [blame] | 44 | #include "workloads/NeonNegWorkload.hpp" |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 45 | #include "workloads/NeonNormalizationFloatWorkload.hpp" |
| 46 | #include "workloads/NeonFullyConnectedWorkload.hpp" |
Éanna Ó Catháin | 1205574 | 2019-01-25 10:01:40 +0000 | [diff] [blame] | 47 | #include "workloads/NeonPadWorkload.hpp" |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 48 | #include "workloads/NeonPermuteWorkload.hpp" |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 49 | #include "workloads/NeonPooling2dWorkload.hpp" |
Nikhil Raj | 9b46148 | 2019-07-03 15:58:31 +0100 | [diff] [blame] | 50 | #include "workloads/NeonPreluWorkload.hpp" |
Sadik Armagan | fabc289 | 2019-05-31 09:05:11 +0100 | [diff] [blame] | 51 | #include "workloads/NeonQuantizeWorkload.hpp" |
Francis Murtagh | 4fc3c48 | 2019-08-02 13:20:54 +0100 | [diff] [blame] | 52 | #include "workloads/NeonQuantizedLstmWorkload.hpp" |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 53 | #include "workloads/NeonReshapeWorkload.hpp" |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 54 | #include "workloads/NeonResizeWorkload.hpp" |
Aron Virginas-Tar | 0dd3b43 | 2019-09-10 13:55:09 +0100 | [diff] [blame] | 55 | #include "workloads/NeonRsqrtWorkload.hpp" |
josh minor | 036f02d | 2019-11-15 14:53:22 -0600 | [diff] [blame] | 56 | #include "workloads/NeonSliceWorkload.hpp" |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 57 | #include "workloads/NeonSoftmaxBaseWorkload.hpp" |
Mike Kelly | 0be3a88 | 2020-01-24 11:27:50 +0000 | [diff] [blame] | 58 | #include "workloads/NeonSpaceToBatchNdWorkload.hpp" |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 59 | #include "workloads/NeonSpaceToDepthWorkload.hpp" |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 60 | #include "workloads/NeonSplitterWorkload.hpp" |
Matthew Jackson | 87f65ea | 2019-08-01 10:01:34 +0100 | [diff] [blame] | 61 | #include "workloads/NeonStackWorkload.hpp" |
FinnWilliamsArm | 1fa1919 | 2019-08-02 17:26:31 +0100 | [diff] [blame] | 62 | #include "workloads/NeonStridedSliceWorkload.hpp" |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 63 | #include "workloads/NeonSubtractionWorkload.hpp" |
Sadik Armagan | 581742d | 2019-08-12 14:11:37 +0100 | [diff] [blame] | 64 | #include "workloads/NeonTransposeConvolution2dWorkload.hpp" |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 65 | #include "workloads/NeonTransposeWorkload.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 66 | #endif |
| 67 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 68 | namespace armnn |
| 69 | { |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 70 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 71 | namespace |
arovir01 | 7ff76c5 | 2018-10-09 09:40:58 +0100 | [diff] [blame] | 72 | { |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 73 | |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 74 | template< typename ... Args> |
| 75 | bool IsNeonBackendSupported(Optional<std::string&> reasonIfUnsupported, Args... args) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 76 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 77 | IgnoreUnused(reasonIfUnsupported, (args)...); |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 78 | #if defined(ARMCOMPUTENEON_ENABLED) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 79 | return true; |
| 80 | #else |
Derek Lamberti | 0790dce | 2019-04-15 18:37:35 +0100 | [diff] [blame] | 81 | SetValueChecked(reasonIfUnsupported, "The armnn library has been built without NEON support"); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 82 | return false; |
| 83 | #endif |
| 84 | } |
| 85 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 86 | template<typename FloatFunc, typename Uint8Func, typename ... Params> |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 87 | bool IsSupportedForDataTypeNeon(Optional<std::string&> reasonIfUnsupported, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 88 | DataType dataType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 89 | FloatFunc floatFuncPtr, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 90 | Uint8Func uint8FuncPtr, |
| 91 | Params&&... params) |
| 92 | { |
| 93 | return IsNeonBackendSupported(reasonIfUnsupported) && |
| 94 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 95 | dataType, |
| 96 | floatFuncPtr, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 97 | floatFuncPtr, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 98 | uint8FuncPtr, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 99 | &FalseFunc<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 100 | &FalseFunc<>, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 101 | std::forward<Params>(params)...); |
| 102 | } |
| 103 | |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 104 | #if defined(ARMCOMPUTENEON_ENABLED) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 105 | template<class FuncType, class... Args> |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 106 | inline bool IsWorkloadSupported(FuncType& func, Optional<std::string&> reasonIfUnsupported, Args&&... args) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 107 | { |
| 108 | arm_compute::Status aclStatus = func(std::forward<Args>(args)...); |
| 109 | const bool supported = (aclStatus.error_code() == arm_compute::ErrorCode::OK); |
| 110 | if (!supported && reasonIfUnsupported) |
| 111 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 112 | reasonIfUnsupported.value() = aclStatus.error_description(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 113 | } |
| 114 | return supported; |
| 115 | } |
| 116 | |
| 117 | #define FORWARD_WORKLOAD_VALIDATE_FUNC(func, reasonIfUnsupported, ...) \ |
| 118 | return IsWorkloadSupported(func, reasonIfUnsupported, __VA_ARGS__); |
| 119 | #else |
| 120 | #define FORWARD_WORKLOAD_VALIDATE_FUNC(func, reasonIfUnsupported, ...) \ |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 121 | return IsNeonBackendSupported(reasonIfUnsupported, __VA_ARGS__); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 122 | #endif |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 123 | } // anonymous namespace |
| 124 | |
Aron Virginas-Tar | 914e4db | 2019-09-09 13:36:45 +0100 | [diff] [blame] | 125 | bool NeonLayerSupport::IsAbsSupported(const TensorInfo& input, |
| 126 | const TensorInfo& output, |
| 127 | Optional<std::string&> reasonIfUnsupported) const |
| 128 | { |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 129 | ElementwiseUnaryDescriptor descriptor(UnaryOperation::Abs); |
| 130 | return IsElementwiseUnarySupported(input, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | 914e4db | 2019-09-09 13:36:45 +0100 | [diff] [blame] | 131 | } |
| 132 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 133 | bool NeonLayerSupport::IsActivationSupported(const TensorInfo& input, |
| 134 | const TensorInfo& output, |
| 135 | const ActivationDescriptor& descriptor, |
| 136 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 137 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 138 | IgnoreUnused(descriptor); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 139 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonActivationWorkloadValidate, |
| 140 | reasonIfUnsupported, |
| 141 | input, |
| 142 | output, |
| 143 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 144 | } |
| 145 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 146 | bool NeonLayerSupport::IsAdditionSupported(const TensorInfo& input0, |
| 147 | const TensorInfo& input1, |
| 148 | const TensorInfo& output, |
| 149 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 150 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 151 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonAdditionWorkloadValidate, |
| 152 | reasonIfUnsupported, |
| 153 | input0, |
| 154 | input1, |
| 155 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 156 | } |
| 157 | |
James Conroy | d47a064 | 2019-09-17 14:22:06 +0100 | [diff] [blame] | 158 | bool NeonLayerSupport::IsArgMinMaxSupported(const TensorInfo& input, |
| 159 | const TensorInfo& output, |
| 160 | const ArgMinMaxDescriptor& descriptor, |
| 161 | Optional<std::string&> reasonIfUnsupported) const |
| 162 | { |
| 163 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonArgMinMaxWorkloadValidate, |
| 164 | reasonIfUnsupported, |
| 165 | input, |
| 166 | output, |
| 167 | descriptor); |
| 168 | } |
| 169 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 170 | bool NeonLayerSupport::IsBatchNormalizationSupported(const TensorInfo& input, |
| 171 | const TensorInfo& output, |
| 172 | const TensorInfo& mean, |
| 173 | const TensorInfo& var, |
| 174 | const TensorInfo& beta, |
| 175 | const TensorInfo& gamma, |
| 176 | const BatchNormalizationDescriptor& descriptor, |
| 177 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 178 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 179 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonBatchNormalizationValidate, |
| 180 | reasonIfUnsupported, |
| 181 | input, |
| 182 | output, |
| 183 | mean, |
| 184 | var, |
| 185 | beta, |
| 186 | gamma, |
| 187 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 188 | } |
| 189 | |
Mike Kelly | 5685802 | 2020-01-27 12:14:47 +0000 | [diff] [blame] | 190 | bool NeonLayerSupport::IsBatchToSpaceNdSupported(const TensorInfo& input, |
| 191 | const TensorInfo& output, |
| 192 | const BatchToSpaceNdDescriptor& descriptor, |
| 193 | Optional<std::string&> reasonIfUnsupported) const |
| 194 | { |
| 195 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonBatchToSpaceNdWorkloadValidate, |
| 196 | reasonIfUnsupported, |
| 197 | input, |
| 198 | output, |
| 199 | descriptor); |
| 200 | } |
| 201 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 202 | bool NeonLayerSupport::IsComparisonSupported(const TensorInfo& input0, |
| 203 | const TensorInfo& input1, |
| 204 | const TensorInfo& output, |
| 205 | const ComparisonDescriptor& descriptor, |
| 206 | Optional<std::string&> reasonIfUnsupported) const |
| 207 | { |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 208 | |
Teresa Charlin | cedd34f | 2020-03-30 11:17:30 +0100 | [diff] [blame] | 209 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonComparisonWorkloadValidate, |
| 210 | reasonIfUnsupported, |
| 211 | input0, |
| 212 | input1, |
| 213 | output, |
| 214 | descriptor); |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 215 | } |
| 216 | |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 217 | bool NeonLayerSupport::IsConcatSupported(const std::vector<const TensorInfo*> inputs, |
| 218 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 219 | const ConcatDescriptor& descriptor, |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 220 | Optional<std::string&> reasonIfUnsupported) const |
| 221 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 222 | if (descriptor.GetNumDimensions() <= descriptor.GetConcatAxis()) |
| 223 | { |
| 224 | SetValueChecked(reasonIfUnsupported, "Neon Concat: Concat axis > Number of dimensions."); |
| 225 | return false; |
| 226 | } |
| 227 | |
| 228 | unsigned int concatInnerAxis = (descriptor.GetNumDimensions() - descriptor.GetConcatAxis()) - 1; |
| 229 | if(concatInnerAxis < 3) // Width, height, or channels |
| 230 | { |
| 231 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonConcatWorkloadValidate, |
| 232 | reasonIfUnsupported, |
| 233 | inputs, |
| 234 | output, |
| 235 | descriptor); |
| 236 | } |
| 237 | else if (concatInnerAxis == 3) |
| 238 | { |
| 239 | for (auto& input : inputs) |
| 240 | { |
| 241 | if (input && !output.IsTypeSpaceMatch(*input)) // Cannot use sub-tensors if the types are not same space |
| 242 | { |
| 243 | SetValueChecked(reasonIfUnsupported, "Neon Concat: Types and quantization parameters must match."); |
| 244 | return false; |
| 245 | } |
| 246 | } |
| 247 | return true; // Sub-tensors support concat along batch |
| 248 | } |
| 249 | else // > 4 dimensions not supported. |
| 250 | { |
| 251 | SetValueChecked(reasonIfUnsupported, "Neon Concat: Maximum of 4 dimensions supported."); |
| 252 | return false; |
| 253 | } |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 254 | } |
| 255 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 256 | bool NeonLayerSupport::IsConstantSupported(const TensorInfo& output, |
| 257 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 258 | { |
Mike Kelly | 0886ac4 | 2020-04-27 09:55:40 +0100 | [diff] [blame] | 259 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonConstantWorkloadValidate, |
| 260 | reasonIfUnsupported, |
| 261 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 262 | } |
| 263 | |
Narumol Prangnawarat | 250d392 | 2020-03-30 16:11:04 +0100 | [diff] [blame] | 264 | bool NeonLayerSupport::IsConvertBf16ToFp32Supported(const TensorInfo& input, |
| 265 | const TensorInfo& output, |
| 266 | Optional<std::string&> reasonIfUnsupported) const |
| 267 | { |
| 268 | armnn::IgnoreUnused(input); |
| 269 | armnn::IgnoreUnused(output); |
| 270 | armnn::IgnoreUnused(reasonIfUnsupported); |
| 271 | return true; |
| 272 | } |
| 273 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 274 | bool NeonLayerSupport::IsConvertFp16ToFp32Supported(const TensorInfo& input, |
| 275 | const TensorInfo& output, |
| 276 | Optional<std::string&> reasonIfUnsupported) const |
| 277 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 278 | armnn::IgnoreUnused(input); |
| 279 | armnn::IgnoreUnused(output); |
| 280 | armnn::IgnoreUnused(reasonIfUnsupported); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 281 | return true; |
| 282 | } |
| 283 | |
Narumol Prangnawarat | 250d392 | 2020-03-30 16:11:04 +0100 | [diff] [blame] | 284 | bool NeonLayerSupport::IsConvertFp32ToBf16Supported(const TensorInfo& input, |
| 285 | const TensorInfo& output, |
| 286 | Optional<std::string&> reasonIfUnsupported) const |
| 287 | { |
| 288 | armnn::IgnoreUnused(input); |
| 289 | armnn::IgnoreUnused(output); |
| 290 | armnn::IgnoreUnused(reasonIfUnsupported); |
| 291 | return true; |
| 292 | } |
| 293 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 294 | bool NeonLayerSupport::IsConvertFp32ToFp16Supported(const TensorInfo& input, |
| 295 | const TensorInfo& output, |
| 296 | Optional<std::string&> reasonIfUnsupported) const |
| 297 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 298 | armnn::IgnoreUnused(input); |
| 299 | armnn::IgnoreUnused(output); |
| 300 | armnn::IgnoreUnused(reasonIfUnsupported); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 301 | return true; |
| 302 | } |
| 303 | |
| 304 | bool NeonLayerSupport::IsConvolution2dSupported(const TensorInfo& input, |
| 305 | const TensorInfo& output, |
| 306 | const Convolution2dDescriptor& descriptor, |
| 307 | const TensorInfo& weights, |
| 308 | const Optional<TensorInfo>& biases, |
| 309 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 310 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 311 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonConvolution2dWorkloadValidate, |
| 312 | reasonIfUnsupported, |
| 313 | input, |
| 314 | output, |
| 315 | descriptor, |
| 316 | weights, |
| 317 | biases); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 318 | } |
| 319 | |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 320 | bool NeonLayerSupport::IsDepthToSpaceSupported(const TensorInfo& input, |
| 321 | const TensorInfo& output, |
| 322 | const DepthToSpaceDescriptor& descriptor, |
| 323 | Optional<std::string&> reasonIfUnsupported) const |
| 324 | { |
| 325 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonDepthToSpaceWorkloadValidate, |
| 326 | reasonIfUnsupported, |
| 327 | input, |
| 328 | output, |
| 329 | descriptor); |
| 330 | } |
| 331 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 332 | bool NeonLayerSupport::IsDepthwiseConvolutionSupported(const TensorInfo& input, |
| 333 | const TensorInfo& output, |
| 334 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 335 | const TensorInfo& weights, |
| 336 | const Optional<TensorInfo>& biases, |
| 337 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 338 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 339 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonDepthwiseConvolutionWorkloadValidate, |
| 340 | reasonIfUnsupported, |
| 341 | input, |
| 342 | output, |
| 343 | descriptor, |
| 344 | weights, |
| 345 | biases); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 346 | } |
| 347 | |
Narumol Prangnawarat | 01961a7 | 2019-05-30 16:47:12 +0100 | [diff] [blame] | 348 | bool NeonLayerSupport::IsDequantizeSupported(const TensorInfo& input, |
| 349 | const TensorInfo& output, |
| 350 | Optional<std::string&> reasonIfUnsupported) const |
| 351 | { |
| 352 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonDequantizeWorkloadValidate, |
| 353 | reasonIfUnsupported, |
| 354 | input, |
| 355 | output); |
| 356 | } |
| 357 | |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 358 | bool NeonLayerSupport::IsDilatedDepthwiseConvolutionSupported(const TensorInfo& input, |
| 359 | const TensorInfo& output, |
| 360 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 361 | const TensorInfo& weights, |
| 362 | const Optional<TensorInfo>& biases, |
| 363 | Optional<std::string&> reasonIfUnsupported) const |
| 364 | { |
| 365 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonDepthwiseConvolutionWorkloadValidate, |
| 366 | reasonIfUnsupported, |
| 367 | input, |
| 368 | output, |
| 369 | descriptor, |
| 370 | weights, |
| 371 | biases); |
| 372 | } |
| 373 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 374 | bool NeonLayerSupport::IsElementwiseUnarySupported(const TensorInfo& input, |
| 375 | const TensorInfo& output, |
| 376 | const ElementwiseUnaryDescriptor& descriptor, |
| 377 | Optional<std::string&> reasonIfUnsupported) const |
| 378 | { |
Derek Lamberti | c77874a | 2020-04-28 13:34:56 +0100 | [diff] [blame^] | 379 | switch(descriptor.m_Operation) |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 380 | { |
Derek Lamberti | c77874a | 2020-04-28 13:34:56 +0100 | [diff] [blame^] | 381 | case UnaryOperation::Abs: |
| 382 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonAbsWorkloadValidate, |
| 383 | reasonIfUnsupported, |
| 384 | input, |
| 385 | output); |
| 386 | case UnaryOperation::Exp: |
| 387 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonExpWorkloadValidate, |
| 388 | reasonIfUnsupported, |
| 389 | input, |
| 390 | output); |
| 391 | case UnaryOperation::Neg: |
| 392 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonNegWorkloadValidate, |
| 393 | reasonIfUnsupported, |
| 394 | input, |
| 395 | output); |
| 396 | case UnaryOperation::Rsqrt: |
| 397 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonRsqrtWorkloadValidate, |
| 398 | reasonIfUnsupported, |
| 399 | input, |
| 400 | output); |
| 401 | default: |
| 402 | return false; |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 403 | } |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 404 | } |
| 405 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 406 | bool NeonLayerSupport::IsFloorSupported(const TensorInfo& input, |
| 407 | const TensorInfo& output, |
| 408 | Optional<std::string&> reasonIfUnsupported) const |
| 409 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 410 | armnn::IgnoreUnused(output); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 411 | return IsNeonBackendSupported(reasonIfUnsupported) && |
| 412 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 413 | input.GetDataType(), |
| 414 | &FalseFuncF16<>, |
| 415 | &TrueFunc<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 416 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 417 | &FalseFuncI32<>, |
| 418 | &FalseFuncU8<>); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | bool NeonLayerSupport::IsFullyConnectedSupported(const TensorInfo& input, |
| 422 | const TensorInfo& output, |
| 423 | const TensorInfo& weights, |
| 424 | const TensorInfo& biases, |
| 425 | const FullyConnectedDescriptor& descriptor, |
| 426 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 427 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 428 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonFullyConnectedWorkloadValidate, |
| 429 | reasonIfUnsupported, |
| 430 | input, |
| 431 | output, |
| 432 | weights, |
| 433 | biases, |
| 434 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 435 | } |
| 436 | |
kevmay01 | eed8592 | 2019-01-28 08:37:25 +0000 | [diff] [blame] | 437 | bool NeonLayerSupport::IsGreaterSupported(const armnn::TensorInfo& input0, |
| 438 | const armnn::TensorInfo& input1, |
| 439 | const armnn::TensorInfo& output, |
| 440 | armnn::Optional<std::string&> reasonIfUnsupported) const |
| 441 | { |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 442 | ComparisonDescriptor descriptor(ComparisonOperation::Greater); |
| 443 | return IsComparisonSupported(input0, input1, output, descriptor, reasonIfUnsupported); |
kevmay01 | eed8592 | 2019-01-28 08:37:25 +0000 | [diff] [blame] | 444 | } |
| 445 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 446 | bool NeonLayerSupport::IsInputSupported(const TensorInfo& input, |
| 447 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 448 | { |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 449 | return IsNeonBackendSupported(reasonIfUnsupported, input); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 450 | } |
| 451 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 452 | bool NeonLayerSupport::IsInstanceNormalizationSupported(const TensorInfo& input, |
| 453 | const TensorInfo& output, |
| 454 | const InstanceNormalizationDescriptor& descriptor, |
| 455 | Optional<std::string&> reasonIfUnsupported) const |
| 456 | { |
| 457 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonInstanceNormalizationWorkloadValidate, |
| 458 | reasonIfUnsupported, |
| 459 | input, |
| 460 | output, |
| 461 | descriptor); |
| 462 | } |
| 463 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 464 | bool NeonLayerSupport::IsL2NormalizationSupported(const TensorInfo& input, |
| 465 | const TensorInfo& output, |
| 466 | const L2NormalizationDescriptor& descriptor, |
| 467 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 468 | { |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 469 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonL2NormalizationWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 470 | } |
| 471 | |
Jan Eilers | ad5293a | 2019-07-08 09:57:55 +0100 | [diff] [blame] | 472 | bool NeonLayerSupport::IsLstmSupported(const TensorInfo& input, |
| 473 | const TensorInfo& outputStateIn, |
| 474 | const TensorInfo& cellStateIn, |
| 475 | const TensorInfo& scratchBuffer, |
| 476 | const TensorInfo& outputStateOut, |
| 477 | const TensorInfo& cellStateOut, |
| 478 | const TensorInfo& output, |
| 479 | const LstmDescriptor& descriptor, |
| 480 | const LstmInputParamsInfo& paramsInfo, |
| 481 | Optional<std::string&> reasonIfUnsupported) const |
| 482 | { |
| 483 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonLstmFloatWorkloadValidate, |
| 484 | reasonIfUnsupported, |
| 485 | input, |
| 486 | outputStateIn, |
| 487 | cellStateIn, |
| 488 | scratchBuffer, |
| 489 | outputStateOut, |
| 490 | cellStateOut, |
| 491 | output, |
| 492 | descriptor, |
| 493 | paramsInfo); |
| 494 | } |
| 495 | |
Nattapat Chaimanowong | 4e6597a | 2018-12-20 14:14:06 +0000 | [diff] [blame] | 496 | bool NeonLayerSupport::IsMaximumSupported(const TensorInfo& input0, |
| 497 | const TensorInfo& input1, |
| 498 | const TensorInfo& output, |
| 499 | Optional<std::string&> reasonIfUnsupported) const |
| 500 | { |
| 501 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMaximumWorkloadValidate, |
| 502 | reasonIfUnsupported, |
| 503 | input0, |
| 504 | input1, |
| 505 | output); |
| 506 | } |
| 507 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 508 | bool NeonLayerSupport::IsMeanSupported(const TensorInfo& input, |
| 509 | const TensorInfo& output, |
| 510 | const MeanDescriptor& descriptor, |
| 511 | Optional<std::string&> reasonIfUnsupported) const |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 512 | { |
Matthew Bentham | fd89996 | 2018-12-31 15:49:42 +0000 | [diff] [blame] | 513 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMeanWorkloadValidate, |
| 514 | reasonIfUnsupported, |
| 515 | input, |
| 516 | output, |
| 517 | descriptor); |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 518 | } |
| 519 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 520 | bool NeonLayerSupport::IsMergerSupported(const std::vector<const TensorInfo*> inputs, |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 521 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 522 | const MergerDescriptor& descriptor, |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 523 | Optional<std::string&> reasonIfUnsupported) const |
| 524 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 525 | return IsConcatSupported(inputs, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 526 | } |
| 527 | |
Conor Kennedy | 54b2169 | 2019-01-09 07:57:38 +0000 | [diff] [blame] | 528 | bool NeonLayerSupport::IsMinimumSupported(const TensorInfo& input0, |
| 529 | const TensorInfo& input1, |
| 530 | const TensorInfo& output, |
| 531 | Optional<std::string&> reasonIfUnsupported) const |
| 532 | { |
| 533 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMinimumWorkloadValidate, |
| 534 | reasonIfUnsupported, |
| 535 | input0, |
| 536 | input1, |
| 537 | output); |
| 538 | } |
| 539 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 540 | bool NeonLayerSupport::IsMultiplicationSupported(const TensorInfo& input0, |
| 541 | const TensorInfo& input1, |
| 542 | const TensorInfo& output, |
| 543 | Optional<std::string&> reasonIfUnsupported) const |
| 544 | { |
| 545 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMultiplicationWorkloadValidate, |
| 546 | reasonIfUnsupported, |
| 547 | input0, |
| 548 | input1, |
| 549 | output); |
| 550 | } |
| 551 | |
Pablo Tello | e61f071 | 2020-01-23 10:37:17 +0000 | [diff] [blame] | 552 | bool NeonLayerSupport::IsDivisionSupported(const TensorInfo& input0, |
| 553 | const TensorInfo& input1, |
| 554 | const TensorInfo& output, |
| 555 | Optional<std::string&> reasonIfUnsupported) const |
| 556 | { |
| 557 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonDivisionWorkloadValidate, |
| 558 | reasonIfUnsupported, |
| 559 | input0, |
| 560 | input1, |
| 561 | output); |
| 562 | } |
| 563 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 564 | bool NeonLayerSupport::IsNormalizationSupported(const TensorInfo& input, |
| 565 | const TensorInfo& output, |
| 566 | const NormalizationDescriptor& descriptor, |
| 567 | Optional<std::string&> reasonIfUnsupported) const |
| 568 | { |
| 569 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonNormalizationWorkloadValidate, |
| 570 | reasonIfUnsupported, |
| 571 | input, |
| 572 | output, |
| 573 | descriptor); |
| 574 | } |
| 575 | |
| 576 | bool NeonLayerSupport::IsOutputSupported(const TensorInfo& output, |
| 577 | Optional<std::string&> reasonIfUnsupported) const |
| 578 | { |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 579 | return IsNeonBackendSupported(reasonIfUnsupported, output); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 580 | } |
| 581 | |
Éanna Ó Catháin | 1205574 | 2019-01-25 10:01:40 +0000 | [diff] [blame] | 582 | bool NeonLayerSupport::IsPadSupported(const TensorInfo& input, |
| 583 | const TensorInfo& output, |
| 584 | const PadDescriptor& descriptor, |
| 585 | Optional<std::string&> reasonIfUnsupported) const |
| 586 | { |
| 587 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonPadWorkloadValidate, |
| 588 | reasonIfUnsupported, |
| 589 | input, |
| 590 | output, |
| 591 | descriptor); |
| 592 | } |
| 593 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 594 | bool NeonLayerSupport::IsPermuteSupported(const TensorInfo& input, |
| 595 | const TensorInfo& output, |
| 596 | const PermuteDescriptor& descriptor, |
| 597 | Optional<std::string&> reasonIfUnsupported) const |
| 598 | { |
| 599 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonPermuteWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 600 | } |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 601 | |
| 602 | bool NeonLayerSupport::IsPooling2dSupported(const TensorInfo& input, |
| 603 | const TensorInfo& output, |
| 604 | const Pooling2dDescriptor& descriptor, |
| 605 | Optional<std::string&> reasonIfUnsupported) const |
| 606 | { |
| 607 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonPooling2dWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 608 | } |
| 609 | |
Nikhil Raj | 9b46148 | 2019-07-03 15:58:31 +0100 | [diff] [blame] | 610 | bool NeonLayerSupport::IsPreluSupported(const armnn::TensorInfo &input, |
| 611 | const armnn::TensorInfo &alpha, |
| 612 | const armnn::TensorInfo &output, |
| 613 | armnn::Optional<std::string &> reasonIfUnsupported) const |
| 614 | { |
| 615 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonPreluWorkloadValidate, reasonIfUnsupported, input, alpha, output); |
| 616 | } |
| 617 | |
Sadik Armagan | fabc289 | 2019-05-31 09:05:11 +0100 | [diff] [blame] | 618 | bool NeonLayerSupport::IsQuantizeSupported(const TensorInfo& input, |
| 619 | const TensorInfo& output, |
| 620 | Optional<std::string&> reasonIfUnsupported) const |
| 621 | { |
| 622 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonQuantizeWorkloadValidate, |
| 623 | reasonIfUnsupported, |
| 624 | input, |
| 625 | output); |
| 626 | } |
| 627 | |
Francis Murtagh | 4fc3c48 | 2019-08-02 13:20:54 +0100 | [diff] [blame] | 628 | bool NeonLayerSupport::IsQuantizedLstmSupported(const TensorInfo& input, |
| 629 | const TensorInfo& cellStateIn, |
| 630 | const TensorInfo& outputStateIn, |
| 631 | const TensorInfo& cellStateOut, |
| 632 | const TensorInfo& outputStateOut, |
| 633 | const QuantizedLstmInputParamsInfo& paramsInfo, |
| 634 | Optional<std::string&> reasonIfUnsupported) const |
| 635 | { |
| 636 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonQuantizedLstmWorkloadValidate, |
| 637 | reasonIfUnsupported, |
| 638 | input, |
| 639 | cellStateIn, |
| 640 | outputStateIn, |
| 641 | cellStateOut, |
| 642 | outputStateOut, |
| 643 | paramsInfo); |
| 644 | } |
| 645 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 646 | bool NeonLayerSupport::IsReshapeSupported(const TensorInfo& input, |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 647 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 648 | const ReshapeDescriptor& descriptor, |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 649 | Optional<std::string&> reasonIfUnsupported) const |
| 650 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 651 | armnn::IgnoreUnused(descriptor); |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 652 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonReshapeWorkloadValidate, |
| 653 | reasonIfUnsupported, |
| 654 | input, |
| 655 | output); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 656 | } |
| 657 | |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 658 | bool NeonLayerSupport::IsResizeSupported(const TensorInfo& input, |
| 659 | const TensorInfo& output, |
| 660 | const ResizeDescriptor& descriptor, |
| 661 | Optional<std::string&> reasonIfUnsupported) const |
| 662 | { |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 663 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonResizeWorkloadValidate, |
| 664 | reasonIfUnsupported, |
| 665 | input, |
| 666 | output, |
| 667 | descriptor); |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 668 | } |
| 669 | |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame] | 670 | bool NeonLayerSupport::IsResizeBilinearSupported(const TensorInfo& input, |
| 671 | const TensorInfo& output, |
| 672 | Optional<std::string&> reasonIfUnsupported) const |
| 673 | { |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 674 | ResizeDescriptor descriptor; |
| 675 | descriptor.m_Method = ResizeMethod::Bilinear; |
| 676 | descriptor.m_DataLayout = DataLayout::NCHW; |
| 677 | |
| 678 | const TensorShape& outputShape = output.GetShape(); |
| 679 | descriptor.m_TargetHeight = outputShape[2]; |
| 680 | descriptor.m_TargetWidth = outputShape[3]; |
| 681 | |
| 682 | return IsResizeSupported(input, output, descriptor, reasonIfUnsupported); |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame] | 683 | } |
| 684 | |
Aron Virginas-Tar | 0dd3b43 | 2019-09-10 13:55:09 +0100 | [diff] [blame] | 685 | bool NeonLayerSupport::IsRsqrtSupported(const TensorInfo& input, |
| 686 | const TensorInfo& output, |
| 687 | Optional<std::string&> reasonIfUnsupported) const |
| 688 | { |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 689 | ElementwiseUnaryDescriptor descriptor(UnaryOperation::Rsqrt); |
| 690 | return IsElementwiseUnarySupported(input, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | 0dd3b43 | 2019-09-10 13:55:09 +0100 | [diff] [blame] | 691 | } |
| 692 | |
josh minor | 036f02d | 2019-11-15 14:53:22 -0600 | [diff] [blame] | 693 | bool NeonLayerSupport::IsSliceSupported(const TensorInfo& input, |
| 694 | const TensorInfo& output, |
| 695 | const SliceDescriptor& descriptor, |
| 696 | Optional<std::string&> reasonIfUnsupported) const |
| 697 | { |
| 698 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSliceWorkloadValidate, |
| 699 | reasonIfUnsupported, |
| 700 | input, |
| 701 | output, |
| 702 | descriptor); |
| 703 | } |
| 704 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 705 | bool NeonLayerSupport::IsSoftmaxSupported(const TensorInfo& input, |
| 706 | const TensorInfo& output, |
| 707 | const SoftmaxDescriptor& descriptor, |
| 708 | Optional<std::string&> reasonIfUnsupported) const |
| 709 | { |
| 710 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSoftmaxWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 711 | } |
| 712 | |
Mike Kelly | 0be3a88 | 2020-01-24 11:27:50 +0000 | [diff] [blame] | 713 | bool NeonLayerSupport::IsSpaceToBatchNdSupported(const TensorInfo& input, |
| 714 | const TensorInfo& output, |
| 715 | const SpaceToBatchNdDescriptor& descriptor, |
| 716 | Optional<std::string&> reasonIfUnsupported) const |
| 717 | { |
| 718 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSpaceToBatchNdWorkloadValidate, |
| 719 | reasonIfUnsupported, |
| 720 | input, |
| 721 | output, |
| 722 | descriptor); |
| 723 | } |
| 724 | |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 725 | bool NeonLayerSupport::IsSpaceToDepthSupported(const TensorInfo& input, |
Mike Kelly | 0be3a88 | 2020-01-24 11:27:50 +0000 | [diff] [blame] | 726 | const TensorInfo& output, |
| 727 | const SpaceToDepthDescriptor& descriptor, |
| 728 | Optional<std::string&> reasonIfUnsupported) const |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 729 | { |
| 730 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSpaceToDepthWorkloadValidate, |
| 731 | reasonIfUnsupported, |
| 732 | input, |
| 733 | output, |
| 734 | descriptor); |
| 735 | } |
| 736 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 737 | bool NeonLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 738 | const ViewsDescriptor& descriptor, |
| 739 | Optional<std::string&> reasonIfUnsupported) const |
| 740 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 741 | armnn::IgnoreUnused(descriptor); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 742 | return IsSupportedForDataTypeNeon(reasonIfUnsupported, |
| 743 | input.GetDataType(), |
| 744 | &TrueFunc<>, |
| 745 | &TrueFunc<>); |
| 746 | } |
| 747 | |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 748 | bool NeonLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 749 | const std::vector<std::reference_wrapper<TensorInfo>>& outputs, |
| 750 | const ViewsDescriptor& descriptor, |
| 751 | Optional<std::string&> reasonIfUnsupported) const |
| 752 | { |
| 753 | #if defined(ARMCOMPUTENEON_ENABLED) |
| 754 | // Split along the last dimension, cannot use sub-tensors |
| 755 | // as width and height of the sub-tensors do not match |
| 756 | // the width and height of the parent tensor |
| 757 | // in case of input with more than 2D. |
| 758 | std::set<unsigned int> splitAxis = ComputeSplitAxis(descriptor, input.GetShape()); |
| 759 | if (descriptor.GetNumDimensions() > 2 && splitAxis.size() == 1 && |
| 760 | *splitAxis.begin() == descriptor.GetNumDimensions() - 1 ) |
| 761 | { |
| 762 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSplitterWorkloadValidate, |
| 763 | reasonIfUnsupported, |
| 764 | input, |
| 765 | outputs, |
| 766 | *splitAxis.begin()); |
| 767 | } |
| 768 | #endif |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 769 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 770 | for (auto output : outputs) |
| 771 | { |
| 772 | if (!input.IsTypeSpaceMatch(output)) // Cannot use sub-tensors if the types are not same space |
| 773 | { |
| 774 | SetValueChecked(reasonIfUnsupported, "Neon Splitter: Types and quantization parameters must match."); |
| 775 | return false; |
| 776 | } |
| 777 | } |
| 778 | return true; |
| 779 | } |
| 780 | |
Matthew Jackson | 87f65ea | 2019-08-01 10:01:34 +0100 | [diff] [blame] | 781 | bool NeonLayerSupport::IsStackSupported(const std::vector<const TensorInfo*>& inputs, |
| 782 | const TensorInfo& output, |
| 783 | const StackDescriptor& descriptor, |
| 784 | Optional<std::string&> reasonIfUnsupported) const |
| 785 | { |
| 786 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonStackWorkloadValidate, |
| 787 | reasonIfUnsupported, |
| 788 | inputs, |
| 789 | output, |
| 790 | descriptor); |
| 791 | } |
| 792 | |
FinnWilliamsArm | 1fa1919 | 2019-08-02 17:26:31 +0100 | [diff] [blame] | 793 | bool NeonLayerSupport::IsStridedSliceSupported(const TensorInfo& input, |
| 794 | const TensorInfo& output, |
| 795 | const StridedSliceDescriptor& descriptor, |
| 796 | Optional<std::string&> reasonIfUnsupported) const |
| 797 | { |
| 798 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonStridedSliceWorkloadValidate, |
| 799 | reasonIfUnsupported, |
| 800 | input, |
| 801 | output, |
| 802 | descriptor); |
| 803 | } |
| 804 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 805 | bool NeonLayerSupport::IsSubtractionSupported(const TensorInfo& input0, |
| 806 | const TensorInfo& input1, |
| 807 | const TensorInfo& output, |
| 808 | Optional<std::string&> reasonIfUnsupported) const |
| 809 | { |
| 810 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSubtractionWorkloadValidate, |
| 811 | reasonIfUnsupported, |
| 812 | input0, |
| 813 | input1, |
| 814 | output); |
| 815 | } |
| 816 | |
Sadik Armagan | 581742d | 2019-08-12 14:11:37 +0100 | [diff] [blame] | 817 | bool NeonLayerSupport::IsTransposeConvolution2dSupported(const TensorInfo& input, |
| 818 | const TensorInfo& output, |
| 819 | const TransposeConvolution2dDescriptor& descriptor, |
| 820 | const TensorInfo& weights, |
| 821 | const Optional<TensorInfo>& biases, |
| 822 | Optional<std::string&> reasonIfUnsupported) const |
| 823 | { |
| 824 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonTransposeConvolution2dWorkloadValidate, |
| 825 | reasonIfUnsupported, |
| 826 | input, |
| 827 | output, |
| 828 | descriptor, |
| 829 | weights, |
| 830 | biases); |
| 831 | } |
| 832 | |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 833 | bool NeonLayerSupport::IsTransposeSupported(const TensorInfo& input, |
| 834 | const TensorInfo& output, |
| 835 | const TransposeDescriptor& descriptor, |
| 836 | Optional<std::string&> reasonIfUnsupported) const |
| 837 | { |
| 838 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonTransposeWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 839 | } |
| 840 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 841 | } // namespace armnn |