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