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