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