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