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