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