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