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