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 | |
Derek Lamberti | c77874a | 2020-04-28 13:34:56 +0100 | [diff] [blame] | 10 | #include <armnn/Exceptions.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 11 | #include <armnn/Tensor.hpp> |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 12 | #include <armnn/Types.hpp> |
Matteo Martincigh | c601aa6 | 2019-10-29 15:03:22 +0000 | [diff] [blame] | 13 | #include <armnn/BackendRegistry.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 14 | |
Matteo Martincigh | c601aa6 | 2019-10-29 15:03:22 +0000 | [diff] [blame] | 15 | #include <InternalTypes.hpp> |
| 16 | #include <LayerSupportCommon.hpp> |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 17 | #include <armnn/utility/IgnoreUnused.hpp> |
Sadik Armagan | 045f6be | 2020-09-10 13:37:32 +0100 | [diff] [blame] | 18 | #include <armnn/utility/PolymorphicDowncast.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 19 | |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 20 | #if defined(ARMCOMPUTENEON_ENABLED) |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 21 | #include <aclCommon/ArmComputeUtils.hpp> |
Aron Virginas-Tar | 710f664 | 2019-11-27 14:48:32 +0000 | [diff] [blame] | 22 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
Aron Virginas-Tar | 914e4db | 2019-09-09 13:36:45 +0100 | [diff] [blame] | 23 | #include "workloads/NeonAbsWorkload.hpp" |
Matthew Bentham | 955258d | 2018-12-10 10:48:52 +0000 | [diff] [blame] | 24 | #include "workloads/NeonAdditionWorkload.hpp" |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 25 | #include "workloads/NeonActivationWorkload.hpp" |
James Conroy | d47a064 | 2019-09-17 14:22:06 +0100 | [diff] [blame] | 26 | #include "workloads/NeonArgMinMaxWorkload.hpp" |
Matthew Bentham | c48ac8c | 2018-12-12 16:15:59 +0000 | [diff] [blame] | 27 | #include "workloads/NeonBatchNormalizationWorkload.hpp" |
Mike Kelly | 5685802 | 2020-01-27 12:14:47 +0000 | [diff] [blame] | 28 | #include "workloads/NeonBatchToSpaceNdWorkload.hpp" |
Sadik Armagan | 48f011e | 2021-04-21 10:50:34 +0100 | [diff] [blame] | 29 | #include "workloads/NeonCastWorkload.hpp" |
Teresa Charlin | e89dd69 | 2021-09-01 16:30:34 +0100 | [diff] [blame] | 30 | #include "workloads/NeonChannelShuffleWorkload.hpp" |
Teresa Charlin | cedd34f | 2020-03-30 11:17:30 +0100 | [diff] [blame] | 31 | #include "workloads/NeonComparisonWorkload.hpp" |
Teresa Charlin | e89dd69 | 2021-09-01 16:30:34 +0100 | [diff] [blame] | 32 | #include "workloads/NeonConcatWorkload.hpp" |
Mike Kelly | 0886ac4 | 2020-04-27 09:55:40 +0100 | [diff] [blame] | 33 | #include "workloads/NeonConstantWorkload.hpp" |
Nattapat Chaimanowong | 974b65f | 2018-10-15 15:07:34 +0100 | [diff] [blame] | 34 | #include "workloads/NeonConvolution2dWorkload.hpp" |
Teresa Charlin | ec5f7d1 | 2021-10-22 17:15:00 +0100 | [diff] [blame] | 35 | #include "workloads/NeonConvolution3dWorkload.hpp" |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 36 | #include "workloads/NeonDepthToSpaceWorkload.hpp" |
Nattapat Chaimanowong | 7714088 | 2018-10-17 11:12:19 +0100 | [diff] [blame] | 37 | #include "workloads/NeonDepthwiseConvolutionWorkload.hpp" |
Narumol Prangnawarat | 01961a7 | 2019-05-30 16:47:12 +0100 | [diff] [blame] | 38 | #include "workloads/NeonDequantizeWorkload.hpp" |
Teresa Charlin | e89dd69 | 2021-09-01 16:30:34 +0100 | [diff] [blame] | 39 | #include "workloads/NeonExpWorkload.hpp" |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 40 | #include "workloads/NeonInstanceNormalizationWorkload.hpp" |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 41 | #include "workloads/NeonL2NormalizationFloatWorkload.hpp" |
Teresa Charlin | 50de4fa | 2021-05-31 18:47:33 +0100 | [diff] [blame] | 42 | #include "workloads/NeonLogWorkload.hpp" |
Keith Davis | 69e653f | 2020-07-02 11:49:26 +0100 | [diff] [blame] | 43 | #include "workloads/NeonLogSoftmaxWorkload.hpp" |
James Conroy | 177df1e | 2020-11-13 10:18:51 +0000 | [diff] [blame] | 44 | #include "workloads/NeonLogicalAndWorkload.hpp" |
| 45 | #include "workloads/NeonLogicalNotWorkload.hpp" |
| 46 | #include "workloads/NeonLogicalOrWorkload.hpp" |
Jan Eilers | ad5293a | 2019-07-08 09:57:55 +0100 | [diff] [blame] | 47 | #include "workloads/NeonLstmFloatWorkload.hpp" |
Nattapat Chaimanowong | 4e6597a | 2018-12-20 14:14:06 +0000 | [diff] [blame] | 48 | #include "workloads/NeonMaximumWorkload.hpp" |
Matthew Bentham | fd89996 | 2018-12-31 15:49:42 +0000 | [diff] [blame] | 49 | #include "workloads/NeonMeanWorkload.hpp" |
Conor Kennedy | 54b2169 | 2019-01-09 07:57:38 +0000 | [diff] [blame] | 50 | #include "workloads/NeonMinimumWorkload.hpp" |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 51 | #include "workloads/NeonMultiplicationWorkload.hpp" |
Pablo Tello | e61f071 | 2020-01-23 10:37:17 +0000 | [diff] [blame] | 52 | #include "workloads/NeonDivisionWorkload.hpp" |
Sadik Armagan | ac47210 | 2020-03-24 09:54:36 +0000 | [diff] [blame] | 53 | #include "workloads/NeonNegWorkload.hpp" |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 54 | #include "workloads/NeonNormalizationFloatWorkload.hpp" |
| 55 | #include "workloads/NeonFullyConnectedWorkload.hpp" |
Teresa Charlin | f540eb8 | 2020-04-10 19:24:55 +0100 | [diff] [blame] | 56 | #include "workloads/NeonGatherWorkload.hpp" |
Éanna Ó Catháin | 1205574 | 2019-01-25 10:01:40 +0000 | [diff] [blame] | 57 | #include "workloads/NeonPadWorkload.hpp" |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 58 | #include "workloads/NeonPermuteWorkload.hpp" |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 59 | #include "workloads/NeonPooling2dWorkload.hpp" |
Nikhil Raj | 9b46148 | 2019-07-03 15:58:31 +0100 | [diff] [blame] | 60 | #include "workloads/NeonPreluWorkload.hpp" |
James Conroy | cc34093 | 2020-05-12 18:08:52 +0100 | [diff] [blame] | 61 | #include "workloads/NeonQLstmWorkload.hpp" |
Sadik Armagan | fabc289 | 2019-05-31 09:05:11 +0100 | [diff] [blame] | 62 | #include "workloads/NeonQuantizeWorkload.hpp" |
Francis Murtagh | 4fc3c48 | 2019-08-02 13:20:54 +0100 | [diff] [blame] | 63 | #include "workloads/NeonQuantizedLstmWorkload.hpp" |
Sadik Armagan | a274748 | 2021-02-09 10:28:54 +0000 | [diff] [blame] | 64 | #include "workloads/NeonReduceWorkload.hpp" |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 65 | #include "workloads/NeonReshapeWorkload.hpp" |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 66 | #include "workloads/NeonResizeWorkload.hpp" |
Aron Virginas-Tar | 0dd3b43 | 2019-09-10 13:55:09 +0100 | [diff] [blame] | 67 | #include "workloads/NeonRsqrtWorkload.hpp" |
Teresa Charlin | 50de4fa | 2021-05-31 18:47:33 +0100 | [diff] [blame] | 68 | #include "workloads/NeonSinWorkload.hpp" |
josh minor | 036f02d | 2019-11-15 14:53:22 -0600 | [diff] [blame] | 69 | #include "workloads/NeonSliceWorkload.hpp" |
Sadik Armagan | be88a57 | 2020-04-30 11:39:37 +0100 | [diff] [blame] | 70 | #include "workloads/NeonSoftmaxWorkload.hpp" |
Mike Kelly | 0be3a88 | 2020-01-24 11:27:50 +0000 | [diff] [blame] | 71 | #include "workloads/NeonSpaceToBatchNdWorkload.hpp" |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 72 | #include "workloads/NeonSpaceToDepthWorkload.hpp" |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 73 | #include "workloads/NeonSplitterWorkload.hpp" |
Matthew Jackson | 87f65ea | 2019-08-01 10:01:34 +0100 | [diff] [blame] | 74 | #include "workloads/NeonStackWorkload.hpp" |
FinnWilliamsArm | 1fa1919 | 2019-08-02 17:26:31 +0100 | [diff] [blame] | 75 | #include "workloads/NeonStridedSliceWorkload.hpp" |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 76 | #include "workloads/NeonSubtractionWorkload.hpp" |
Sadik Armagan | 581742d | 2019-08-12 14:11:37 +0100 | [diff] [blame] | 77 | #include "workloads/NeonTransposeConvolution2dWorkload.hpp" |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 78 | #include "workloads/NeonTransposeWorkload.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 79 | #endif |
| 80 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 81 | namespace armnn |
| 82 | { |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 83 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 84 | namespace |
arovir01 | 7ff76c5 | 2018-10-09 09:40:58 +0100 | [diff] [blame] | 85 | { |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 86 | |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 87 | template< typename ... Args> |
| 88 | bool IsNeonBackendSupported(Optional<std::string&> reasonIfUnsupported, Args... args) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 89 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 90 | IgnoreUnused(reasonIfUnsupported, (args)...); |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 91 | #if defined(ARMCOMPUTENEON_ENABLED) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 92 | return true; |
| 93 | #else |
Derek Lamberti | 0790dce | 2019-04-15 18:37:35 +0100 | [diff] [blame] | 94 | SetValueChecked(reasonIfUnsupported, "The armnn library has been built without NEON support"); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 95 | return false; |
| 96 | #endif |
| 97 | } |
| 98 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 99 | template<typename FloatFunc, typename Uint8Func, typename ... Params> |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 100 | bool IsSupportedForDataTypeNeon(Optional<std::string&> reasonIfUnsupported, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 101 | DataType dataType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 102 | FloatFunc floatFuncPtr, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 103 | Uint8Func uint8FuncPtr, |
| 104 | Params&&... params) |
| 105 | { |
| 106 | return IsNeonBackendSupported(reasonIfUnsupported) && |
| 107 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 108 | dataType, |
| 109 | floatFuncPtr, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 110 | floatFuncPtr, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 111 | uint8FuncPtr, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 112 | &FalseFunc<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 113 | &FalseFunc<>, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 114 | std::forward<Params>(params)...); |
| 115 | } |
| 116 | |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 117 | #if defined(ARMCOMPUTENEON_ENABLED) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 118 | template<class FuncType, class... Args> |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 119 | inline bool IsWorkloadSupported(FuncType& func, Optional<std::string&> reasonIfUnsupported, Args&&... args) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 120 | { |
| 121 | arm_compute::Status aclStatus = func(std::forward<Args>(args)...); |
| 122 | const bool supported = (aclStatus.error_code() == arm_compute::ErrorCode::OK); |
| 123 | if (!supported && reasonIfUnsupported) |
| 124 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 125 | reasonIfUnsupported.value() = aclStatus.error_description(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 126 | } |
| 127 | return supported; |
| 128 | } |
| 129 | |
| 130 | #define FORWARD_WORKLOAD_VALIDATE_FUNC(func, reasonIfUnsupported, ...) \ |
| 131 | return IsWorkloadSupported(func, reasonIfUnsupported, __VA_ARGS__); |
| 132 | #else |
| 133 | #define FORWARD_WORKLOAD_VALIDATE_FUNC(func, reasonIfUnsupported, ...) \ |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 134 | return IsNeonBackendSupported(reasonIfUnsupported, __VA_ARGS__); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 135 | #endif |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 136 | } // anonymous namespace |
| 137 | |
Sadik Armagan | 045f6be | 2020-09-10 13:37:32 +0100 | [diff] [blame] | 138 | NeonLayerSupport::NeonLayerSupport(const IBackendInternal::IBackendSpecificModelContextPtr& modelContextPtr) |
| 139 | : m_ModelContextPtr(modelContextPtr) |
| 140 | { |
| 141 | } |
| 142 | |
| 143 | NeonLayerSupport::NeonLayerSupport() |
| 144 | : m_ModelContextPtr(nullptr) |
| 145 | { |
| 146 | } |
| 147 | |
Cathal Corbett | 34b429c | 2021-12-24 12:24:40 +0000 | [diff] [blame] | 148 | bool NeonLayerSupport::IsLayerSupported(const LayerType& type, |
| 149 | const std::vector<TensorInfo>& infos, |
| 150 | const BaseDescriptor& descriptor, |
| 151 | const Optional<LstmInputParamsInfo>& lstmParamsInfo, |
| 152 | const Optional<QuantizedLstmInputParamsInfo>& quantizedLstmParamsInfo, |
| 153 | Optional<std::string&> reasonIfUnsupported) const |
| 154 | { |
| 155 | switch (type) |
| 156 | { |
| 157 | case LayerType::Activation: |
| 158 | return IsActivationSupported(infos[0], |
| 159 | infos[1], |
| 160 | *(PolymorphicDowncast<const ActivationDescriptor*>(&descriptor)), |
| 161 | reasonIfUnsupported); |
| 162 | case LayerType::Addition: |
| 163 | return IsAdditionSupported(infos[0], infos[1], infos[2], reasonIfUnsupported); |
| 164 | case LayerType::ArgMinMax: |
| 165 | return IsArgMinMaxSupported(infos[0], |
| 166 | infos[1], |
| 167 | *(PolymorphicDowncast<const ArgMinMaxDescriptor*>(&descriptor)), |
| 168 | reasonIfUnsupported); |
| 169 | case LayerType::BatchNormalization: |
| 170 | return IsBatchNormalizationSupported(infos[0], |
| 171 | infos[1], |
| 172 | infos[2], |
| 173 | infos[3], |
| 174 | infos[4], |
| 175 | infos[5], |
| 176 | *(PolymorphicDowncast<const BatchNormalizationDescriptor*> |
| 177 | (&descriptor)), |
| 178 | reasonIfUnsupported); |
| 179 | case LayerType::BatchToSpaceNd: |
| 180 | return IsBatchToSpaceNdSupported(infos[0], |
| 181 | infos[1], |
| 182 | *(PolymorphicDowncast<const BatchToSpaceNdDescriptor*>(&descriptor)), |
| 183 | reasonIfUnsupported); |
| 184 | case LayerType::Comparison: |
| 185 | return IsComparisonSupported(infos[0], |
| 186 | infos[1], |
| 187 | infos[2], |
| 188 | *(PolymorphicDowncast<const ComparisonDescriptor*>(&descriptor)), |
| 189 | reasonIfUnsupported); |
| 190 | case LayerType::Concat: |
| 191 | { |
| 192 | std::vector<const TensorInfo*> inputInfos; |
| 193 | for (uint32_t i = 0; i < (infos.size() - 1); i++) |
| 194 | { |
| 195 | inputInfos.push_back(&infos[i]); |
| 196 | } |
| 197 | return IsConcatSupported(inputInfos, |
| 198 | infos[infos.size() - 1], |
| 199 | *(PolymorphicDowncast<const OriginsDescriptor*>(&descriptor)), |
| 200 | reasonIfUnsupported); |
| 201 | } |
| 202 | case LayerType::Constant: |
| 203 | return IsConstantSupported(infos[0], reasonIfUnsupported); |
| 204 | case LayerType::ConvertBf16ToFp32: |
| 205 | return IsConvertBf16ToFp32Supported(infos[0], infos[1], reasonIfUnsupported); |
| 206 | case LayerType::ConvertFp16ToFp32: |
| 207 | return IsConvertFp16ToFp32Supported(infos[0], infos[1], reasonIfUnsupported); |
| 208 | case LayerType::ConvertFp32ToBf16: |
| 209 | return IsConvertFp32ToBf16Supported(infos[0], infos[1], reasonIfUnsupported); |
| 210 | case LayerType::ConvertFp32ToFp16: |
| 211 | return IsConvertFp32ToFp16Supported(infos[0], infos[1], reasonIfUnsupported); |
| 212 | case LayerType::Convolution2d: |
| 213 | { |
| 214 | if (infos.size() != 4) |
| 215 | { |
| 216 | throw InvalidArgumentException("Invalid number of TransposeConvolution2d TensorInfos. " |
| 217 | "TensorInfos should be of format: {input, output, weights, biases}."); |
| 218 | } |
| 219 | |
| 220 | auto desc = *(PolymorphicDowncast<const Convolution2dDescriptor*>(&descriptor)); |
| 221 | if (infos[3] == TensorInfo()) |
| 222 | { |
| 223 | return IsConvolution2dSupported(infos[0], |
| 224 | infos[1], |
| 225 | desc, |
| 226 | infos[2], |
| 227 | EmptyOptional(), |
| 228 | reasonIfUnsupported); |
| 229 | } |
| 230 | else |
| 231 | { |
| 232 | return IsConvolution2dSupported(infos[0], |
| 233 | infos[1], |
| 234 | desc, |
| 235 | infos[2], |
| 236 | infos[3], |
| 237 | reasonIfUnsupported); |
| 238 | } |
| 239 | } |
| 240 | case LayerType::DepthToSpace: |
| 241 | return IsDepthToSpaceSupported(infos[0], |
| 242 | infos[1], |
| 243 | *(PolymorphicDowncast<const DepthToSpaceDescriptor*>(&descriptor)), |
| 244 | reasonIfUnsupported); |
| 245 | case LayerType::DepthwiseConvolution2d: |
| 246 | { |
| 247 | if (infos.size() != 4) |
| 248 | { |
| 249 | throw InvalidArgumentException("Invalid number of DepthwiseConvolution2d TensorInfos. " |
| 250 | "TensorInfos should be of format: {input, output, weights, biases}."); |
| 251 | } |
| 252 | |
| 253 | auto desc = *(PolymorphicDowncast<const DepthwiseConvolution2dDescriptor*>(&descriptor)); |
| 254 | if (infos[3] == TensorInfo()) |
| 255 | { |
| 256 | return IsDepthwiseConvolutionSupported(infos[0], |
| 257 | infos[1], |
| 258 | desc, |
| 259 | infos[2], |
| 260 | EmptyOptional(), |
| 261 | reasonIfUnsupported); |
| 262 | } |
| 263 | else |
| 264 | { |
| 265 | return IsDepthwiseConvolutionSupported(infos[0], |
| 266 | infos[1], |
| 267 | desc, |
| 268 | infos[2], |
| 269 | infos[3], |
| 270 | reasonIfUnsupported); |
| 271 | } |
| 272 | } |
| 273 | case LayerType::Dequantize: |
| 274 | return IsDequantizeSupported(infos[0], infos[1], reasonIfUnsupported); |
| 275 | case LayerType::Division: |
| 276 | return IsDivisionSupported(infos[0], infos[1], infos[2], reasonIfUnsupported); |
| 277 | case LayerType::ElementwiseUnary: |
| 278 | return IsElementwiseUnarySupported(infos[0], |
| 279 | infos[1], |
| 280 | *(PolymorphicDowncast<const ElementwiseUnaryDescriptor*>(&descriptor)), |
| 281 | reasonIfUnsupported); |
| 282 | case LayerType::Fill: |
| 283 | return IsFillSupported(infos[0], |
| 284 | infos[1], |
| 285 | *(PolymorphicDowncast<const FillDescriptor*>(&descriptor)), |
| 286 | reasonIfUnsupported); |
| 287 | case LayerType::Floor: |
| 288 | return IsFloorSupported(infos[0], infos[1], reasonIfUnsupported); |
| 289 | case LayerType::FullyConnected: |
| 290 | return IsFullyConnectedSupported(infos[0], |
| 291 | infos[1], |
| 292 | infos[2], |
| 293 | infos[3], |
| 294 | *(PolymorphicDowncast<const FullyConnectedDescriptor*>(&descriptor)), |
| 295 | reasonIfUnsupported); |
| 296 | case LayerType::Gather: |
| 297 | return IsGatherSupported(infos[0], |
| 298 | infos[1], |
| 299 | infos[2], |
| 300 | *(PolymorphicDowncast<const GatherDescriptor*>(&descriptor)), |
| 301 | reasonIfUnsupported); |
| 302 | case LayerType::Input: |
| 303 | return IsInputSupported(infos[0], reasonIfUnsupported); |
| 304 | case LayerType::InstanceNormalization: |
| 305 | return IsInstanceNormalizationSupported(infos[0], |
| 306 | infos[1], |
| 307 | *(PolymorphicDowncast<const InstanceNormalizationDescriptor*> |
| 308 | (&descriptor)), |
| 309 | reasonIfUnsupported); |
| 310 | case LayerType::L2Normalization: |
| 311 | return IsL2NormalizationSupported(infos[0], |
| 312 | infos[1], |
| 313 | *(PolymorphicDowncast<const L2NormalizationDescriptor*>(&descriptor)), |
| 314 | reasonIfUnsupported); |
| 315 | case LayerType::LogicalBinary: |
| 316 | return IsLogicalBinarySupported(infos[0], |
| 317 | infos[1], |
| 318 | infos[2], |
| 319 | *(PolymorphicDowncast<const LogicalBinaryDescriptor*>(&descriptor)), |
| 320 | reasonIfUnsupported); |
| 321 | case LayerType::LogSoftmax: |
| 322 | return IsLogSoftmaxSupported(infos[0], |
| 323 | infos[1], |
| 324 | *(PolymorphicDowncast<const LogSoftmaxDescriptor*>(&descriptor)), |
| 325 | reasonIfUnsupported); |
| 326 | case LayerType::Lstm: |
| 327 | return IsLstmSupported(infos[0], |
| 328 | infos[1], |
| 329 | infos[2], |
| 330 | infos[3], |
| 331 | infos[4], |
| 332 | infos[5], |
| 333 | infos[6], |
| 334 | *(PolymorphicDowncast<const LstmDescriptor*>(&descriptor)), |
| 335 | lstmParamsInfo.value(), |
| 336 | reasonIfUnsupported); |
| 337 | case LayerType::QLstm: |
| 338 | return IsQLstmSupported(infos[0], |
| 339 | infos[1], |
| 340 | infos[2], |
| 341 | infos[3], |
| 342 | infos[4], |
| 343 | infos[5], |
| 344 | *(PolymorphicDowncast<const QLstmDescriptor*>(&descriptor)), |
| 345 | lstmParamsInfo.value(), |
| 346 | reasonIfUnsupported); |
| 347 | case LayerType::Maximum: |
| 348 | return IsMaximumSupported(infos[0], infos[1], infos[2], reasonIfUnsupported); |
| 349 | case LayerType::Mean: |
| 350 | return IsMeanSupported(infos[0], |
| 351 | infos[1], |
| 352 | *(PolymorphicDowncast<const MeanDescriptor*>(&descriptor)), |
| 353 | reasonIfUnsupported); |
| 354 | case LayerType::Minimum: |
| 355 | return IsMinimumSupported(infos[0], infos[1], infos[2], reasonIfUnsupported); |
| 356 | case LayerType::Multiplication: |
| 357 | return IsMultiplicationSupported(infos[0], infos[1], infos[2], reasonIfUnsupported); |
| 358 | case LayerType::Normalization: |
| 359 | return IsNormalizationSupported(infos[0], |
| 360 | infos[1], |
| 361 | *(PolymorphicDowncast<const NormalizationDescriptor*>(&descriptor)), |
| 362 | reasonIfUnsupported); |
| 363 | case LayerType::Output: |
| 364 | return IsOutputSupported(infos[0], reasonIfUnsupported); |
| 365 | case LayerType::Pad: |
| 366 | return IsPadSupported(infos[0], |
| 367 | infos[1], |
| 368 | *(PolymorphicDowncast<const PadDescriptor*>(&descriptor)), |
| 369 | reasonIfUnsupported); |
| 370 | case LayerType::Permute: |
| 371 | return IsPermuteSupported(infos[0], |
| 372 | infos[1], |
| 373 | *(PolymorphicDowncast<const PermuteDescriptor*>(&descriptor)), |
| 374 | reasonIfUnsupported); |
| 375 | case LayerType::Pooling2d: |
| 376 | return IsPooling2dSupported(infos[0], |
| 377 | infos[1], |
| 378 | *(PolymorphicDowncast<const Pooling2dDescriptor*>(&descriptor)), |
| 379 | reasonIfUnsupported); |
| 380 | case LayerType::Prelu: |
| 381 | return IsPreluSupported(infos[0], infos[1], infos[2], reasonIfUnsupported); |
| 382 | case LayerType::Quantize: |
| 383 | return IsQuantizeSupported(infos[0], infos[1], reasonIfUnsupported); |
| 384 | case LayerType::QuantizedLstm: |
| 385 | return IsQuantizedLstmSupported(infos[0], |
| 386 | infos[1], |
| 387 | infos[2], |
| 388 | infos[3], |
| 389 | infos[4], |
| 390 | quantizedLstmParamsInfo.value(), |
| 391 | reasonIfUnsupported); |
| 392 | case LayerType::Reshape: |
| 393 | return IsReshapeSupported(infos[0], |
| 394 | infos[1], |
| 395 | *(PolymorphicDowncast<const ReshapeDescriptor*>(&descriptor)), |
| 396 | reasonIfUnsupported); |
| 397 | case LayerType::Resize: |
| 398 | return IsResizeSupported(infos[0], |
| 399 | infos[1], |
| 400 | *(PolymorphicDowncast<const ResizeDescriptor*>(&descriptor)), |
| 401 | reasonIfUnsupported); |
| 402 | case LayerType::Reduce: |
| 403 | return IsReduceSupported(infos[0], |
| 404 | infos[1], |
| 405 | *(PolymorphicDowncast<const ReduceDescriptor*>(&descriptor)), |
| 406 | reasonIfUnsupported); |
| 407 | case LayerType::Slice: |
| 408 | return IsSliceSupported(infos[0], |
| 409 | infos[1], |
| 410 | *(PolymorphicDowncast<const SliceDescriptor*>(&descriptor)), |
| 411 | reasonIfUnsupported); |
| 412 | case LayerType::Softmax: |
| 413 | return IsSoftmaxSupported(infos[0], |
| 414 | infos[1], |
| 415 | *(PolymorphicDowncast<const SoftmaxDescriptor*>(&descriptor)), |
| 416 | reasonIfUnsupported); |
| 417 | case LayerType::SpaceToBatchNd: |
| 418 | return IsSpaceToBatchNdSupported(infos[0], |
| 419 | infos[1], |
| 420 | *(PolymorphicDowncast<const SpaceToBatchNdDescriptor*>(&descriptor)), |
| 421 | reasonIfUnsupported); |
| 422 | case LayerType::SpaceToDepth: |
| 423 | return IsSpaceToDepthSupported(infos[0], |
| 424 | infos[1], |
| 425 | *(PolymorphicDowncast<const SpaceToDepthDescriptor*>(&descriptor)), |
| 426 | reasonIfUnsupported); |
| 427 | case LayerType::Splitter: |
| 428 | { |
| 429 | std::vector<TensorInfo> outputInfos; |
| 430 | for (uint32_t i = 1; i < infos.size(); i++) |
| 431 | { |
| 432 | outputInfos.push_back(infos[i]); |
| 433 | } |
| 434 | return IsSplitterSupported(infos[0], |
| 435 | {outputInfos.begin(), outputInfos.end()}, |
| 436 | *(PolymorphicDowncast<const ViewsDescriptor*>(&descriptor)), |
| 437 | reasonIfUnsupported); |
| 438 | } |
| 439 | case LayerType::Stack: |
| 440 | { |
| 441 | std::vector<const TensorInfo*> inputInfos; |
| 442 | for (uint32_t i = 0; i < infos.size() - 1; i++) |
| 443 | { |
| 444 | inputInfos.push_back(&infos[i]); |
| 445 | } |
| 446 | return IsStackSupported(inputInfos, |
| 447 | infos[infos.size() - 1], |
| 448 | *(PolymorphicDowncast<const StackDescriptor*>(&descriptor)), |
| 449 | reasonIfUnsupported); |
| 450 | } |
| 451 | case LayerType::StridedSlice: |
| 452 | return IsStridedSliceSupported(infos[0], |
| 453 | infos[1], |
| 454 | *(PolymorphicDowncast<const StridedSliceDescriptor*>(&descriptor)), |
| 455 | reasonIfUnsupported); |
| 456 | case LayerType::Subtraction: |
| 457 | return IsSubtractionSupported(infos[0], infos[1], infos[2], reasonIfUnsupported); |
| 458 | case LayerType::Transpose: |
| 459 | return IsTransposeSupported(infos[0], |
| 460 | infos[1], |
| 461 | *(PolymorphicDowncast<const TransposeDescriptor*>(&descriptor)), |
| 462 | reasonIfUnsupported); |
| 463 | case LayerType::TransposeConvolution2d: |
| 464 | { |
| 465 | if (infos.size() != 4) |
| 466 | { |
| 467 | throw InvalidArgumentException("Invalid number of TransposeConvolution2d TensorInfos. " |
| 468 | "TensorInfos should be of format: {input, output, weights, biases}."); |
| 469 | } |
| 470 | |
| 471 | auto desc = *(PolymorphicDowncast<const TransposeConvolution2dDescriptor*>(&descriptor)); |
| 472 | if (infos[3] == TensorInfo()) |
| 473 | { |
| 474 | return IsTransposeConvolution2dSupported(infos[0], |
| 475 | infos[1], |
| 476 | desc, |
| 477 | infos[2], |
| 478 | EmptyOptional(), |
| 479 | reasonIfUnsupported); |
| 480 | } |
| 481 | else |
| 482 | { |
| 483 | return IsTransposeConvolution2dSupported(infos[0], |
| 484 | infos[1], |
| 485 | desc, |
| 486 | infos[2], |
| 487 | infos[3], |
| 488 | reasonIfUnsupported); |
| 489 | } |
| 490 | } |
| 491 | case LayerType::Cast: |
| 492 | return IsCastSupported(infos[0], infos[1], reasonIfUnsupported); |
| 493 | case LayerType::ChannelShuffle: |
| 494 | return IsChannelShuffleSupported(infos[0], |
| 495 | infos[1], |
| 496 | *(PolymorphicDowncast<const ChannelShuffleDescriptor*>(&descriptor)), |
| 497 | reasonIfUnsupported); |
| 498 | case LayerType::Convolution3d: |
| 499 | { |
| 500 | if (infos.size() != 4) |
| 501 | { |
| 502 | throw InvalidArgumentException("Invalid number of Convolution3d TensorInfos. " |
| 503 | "TensorInfos should be of format: {input, output, weights, biases}."); |
| 504 | } |
| 505 | |
| 506 | auto desc = *(PolymorphicDowncast<const Convolution3dDescriptor*>(&descriptor)); |
| 507 | if (infos[3] == TensorInfo()) |
| 508 | { |
| 509 | return IsConvolution3dSupported(infos[0], |
| 510 | infos[1], |
| 511 | desc, |
| 512 | infos[2], |
| 513 | EmptyOptional(), |
| 514 | reasonIfUnsupported); |
| 515 | } |
| 516 | else |
| 517 | { |
| 518 | return IsConvolution3dSupported(infos[0], |
| 519 | infos[1], |
| 520 | desc, |
| 521 | infos[2], |
| 522 | infos[3], |
| 523 | reasonIfUnsupported); |
| 524 | } |
| 525 | } |
| 526 | case LayerType::MemCopy: |
| 527 | return LayerSupportBase::IsMemCopySupported(infos[0], infos[1], reasonIfUnsupported); |
| 528 | case LayerType::MemImport: |
| 529 | return LayerSupportBase::IsMemImportSupported(infos[0], infos[1], reasonIfUnsupported); |
| 530 | case LayerType::DetectionPostProcess: |
| 531 | { |
| 532 | auto desc = *(PolymorphicDowncast<const DetectionPostProcessDescriptor*>(&descriptor)); |
| 533 | return LayerSupportBase::IsDetectionPostProcessSupported(infos[0], |
| 534 | infos[1], |
| 535 | infos[2], |
| 536 | infos[3], |
| 537 | infos[4], |
| 538 | infos[5], |
| 539 | infos[6], |
| 540 | desc, |
| 541 | reasonIfUnsupported); |
| 542 | } |
| 543 | case LayerType::Map: |
| 544 | return true; |
| 545 | case LayerType::Unmap: |
| 546 | return true; |
| 547 | case LayerType::Merge: |
| 548 | return LayerSupportBase::IsMergeSupported(infos[0], |
| 549 | infos[1], |
| 550 | infos[2], |
| 551 | reasonIfUnsupported); |
| 552 | case LayerType::Rank: |
| 553 | return true; |
| 554 | case LayerType::Shape: |
| 555 | return LayerSupportBase::IsShapeSupported(infos[0], |
| 556 | infos[1], |
| 557 | reasonIfUnsupported); |
| 558 | default: |
| 559 | // layers not supported in neon by default: |
| 560 | // debug, fakequantization, precompiled, standin, |
| 561 | // switch, unidirectionalsequencelstm, pooling3d |
| 562 | return false; |
| 563 | } |
| 564 | } |
| 565 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 566 | bool NeonLayerSupport::IsActivationSupported(const TensorInfo& input, |
| 567 | const TensorInfo& output, |
| 568 | const ActivationDescriptor& descriptor, |
| 569 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 570 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 571 | IgnoreUnused(descriptor); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 572 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonActivationWorkloadValidate, |
| 573 | reasonIfUnsupported, |
| 574 | input, |
| 575 | output, |
| 576 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 577 | } |
| 578 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 579 | bool NeonLayerSupport::IsAdditionSupported(const TensorInfo& input0, |
| 580 | const TensorInfo& input1, |
| 581 | const TensorInfo& output, |
| 582 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 583 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 584 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonAdditionWorkloadValidate, |
| 585 | reasonIfUnsupported, |
| 586 | input0, |
| 587 | input1, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 588 | output, |
| 589 | nullptr); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 590 | } |
| 591 | |
James Conroy | d47a064 | 2019-09-17 14:22:06 +0100 | [diff] [blame] | 592 | bool NeonLayerSupport::IsArgMinMaxSupported(const TensorInfo& input, |
| 593 | const TensorInfo& output, |
| 594 | const ArgMinMaxDescriptor& descriptor, |
| 595 | Optional<std::string&> reasonIfUnsupported) const |
| 596 | { |
| 597 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonArgMinMaxWorkloadValidate, |
| 598 | reasonIfUnsupported, |
| 599 | input, |
| 600 | output, |
| 601 | descriptor); |
| 602 | } |
| 603 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 604 | bool NeonLayerSupport::IsBatchNormalizationSupported(const TensorInfo& input, |
| 605 | const TensorInfo& output, |
| 606 | const TensorInfo& mean, |
| 607 | const TensorInfo& var, |
| 608 | const TensorInfo& beta, |
| 609 | const TensorInfo& gamma, |
| 610 | const BatchNormalizationDescriptor& descriptor, |
| 611 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 612 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 613 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonBatchNormalizationValidate, |
| 614 | reasonIfUnsupported, |
| 615 | input, |
| 616 | output, |
| 617 | mean, |
| 618 | var, |
| 619 | beta, |
| 620 | gamma, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 621 | descriptor, |
| 622 | nullptr); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 623 | } |
| 624 | |
Mike Kelly | 5685802 | 2020-01-27 12:14:47 +0000 | [diff] [blame] | 625 | bool NeonLayerSupport::IsBatchToSpaceNdSupported(const TensorInfo& input, |
| 626 | const TensorInfo& output, |
| 627 | const BatchToSpaceNdDescriptor& descriptor, |
| 628 | Optional<std::string&> reasonIfUnsupported) const |
| 629 | { |
| 630 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonBatchToSpaceNdWorkloadValidate, |
| 631 | reasonIfUnsupported, |
| 632 | input, |
| 633 | output, |
| 634 | descriptor); |
| 635 | } |
| 636 | |
Sadik Armagan | 48f011e | 2021-04-21 10:50:34 +0100 | [diff] [blame] | 637 | bool NeonLayerSupport::IsCastSupported(const TensorInfo& input, |
| 638 | const TensorInfo& output, |
| 639 | Optional<std::string&> reasonIfUnsupported) const |
| 640 | { |
| 641 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonCastValidate, |
| 642 | reasonIfUnsupported, |
| 643 | input, |
| 644 | output); |
| 645 | } |
| 646 | |
Teresa Charlin | e89dd69 | 2021-09-01 16:30:34 +0100 | [diff] [blame] | 647 | bool NeonLayerSupport::IsChannelShuffleSupported(const TensorInfo& input, |
| 648 | const TensorInfo& output, |
| 649 | const ChannelShuffleDescriptor& descriptor, |
| 650 | Optional<std::string&> reasonIfUnsupported) const |
| 651 | { |
| 652 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonChannelShuffleValidate, |
| 653 | reasonIfUnsupported, |
| 654 | input, |
| 655 | output, |
| 656 | descriptor); |
| 657 | } |
| 658 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 659 | bool NeonLayerSupport::IsComparisonSupported(const TensorInfo& input0, |
| 660 | const TensorInfo& input1, |
| 661 | const TensorInfo& output, |
| 662 | const ComparisonDescriptor& descriptor, |
| 663 | Optional<std::string&> reasonIfUnsupported) const |
| 664 | { |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 665 | |
Teresa Charlin | cedd34f | 2020-03-30 11:17:30 +0100 | [diff] [blame] | 666 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonComparisonWorkloadValidate, |
| 667 | reasonIfUnsupported, |
| 668 | input0, |
| 669 | input1, |
| 670 | output, |
| 671 | descriptor); |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 672 | } |
| 673 | |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 674 | bool NeonLayerSupport::IsConcatSupported(const std::vector<const TensorInfo*> inputs, |
| 675 | const TensorInfo& output, |
Cathal Corbett | 34b429c | 2021-12-24 12:24:40 +0000 | [diff] [blame] | 676 | const OriginsDescriptor& descriptor, |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 677 | Optional<std::string&> reasonIfUnsupported) const |
| 678 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 679 | if (descriptor.GetNumDimensions() <= descriptor.GetConcatAxis()) |
| 680 | { |
| 681 | SetValueChecked(reasonIfUnsupported, "Neon Concat: Concat axis > Number of dimensions."); |
| 682 | return false; |
| 683 | } |
| 684 | |
| 685 | unsigned int concatInnerAxis = (descriptor.GetNumDimensions() - descriptor.GetConcatAxis()) - 1; |
| 686 | if(concatInnerAxis < 3) // Width, height, or channels |
| 687 | { |
| 688 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonConcatWorkloadValidate, |
| 689 | reasonIfUnsupported, |
| 690 | inputs, |
| 691 | output, |
| 692 | descriptor); |
| 693 | } |
| 694 | else if (concatInnerAxis == 3) |
| 695 | { |
| 696 | for (auto& input : inputs) |
| 697 | { |
| 698 | if (input && !output.IsTypeSpaceMatch(*input)) // Cannot use sub-tensors if the types are not same space |
| 699 | { |
| 700 | SetValueChecked(reasonIfUnsupported, "Neon Concat: Types and quantization parameters must match."); |
| 701 | return false; |
| 702 | } |
| 703 | } |
| 704 | return true; // Sub-tensors support concat along batch |
| 705 | } |
| 706 | else // > 4 dimensions not supported. |
| 707 | { |
| 708 | SetValueChecked(reasonIfUnsupported, "Neon Concat: Maximum of 4 dimensions supported."); |
| 709 | return false; |
| 710 | } |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 711 | } |
| 712 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 713 | bool NeonLayerSupport::IsConstantSupported(const TensorInfo& output, |
| 714 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 715 | { |
Mike Kelly | 0886ac4 | 2020-04-27 09:55:40 +0100 | [diff] [blame] | 716 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonConstantWorkloadValidate, |
| 717 | reasonIfUnsupported, |
| 718 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 719 | } |
| 720 | |
Narumol Prangnawarat | 250d392 | 2020-03-30 16:11:04 +0100 | [diff] [blame] | 721 | bool NeonLayerSupport::IsConvertBf16ToFp32Supported(const TensorInfo& input, |
| 722 | const TensorInfo& output, |
| 723 | Optional<std::string&> reasonIfUnsupported) const |
| 724 | { |
| 725 | armnn::IgnoreUnused(input); |
| 726 | armnn::IgnoreUnused(output); |
| 727 | armnn::IgnoreUnused(reasonIfUnsupported); |
| 728 | return true; |
| 729 | } |
| 730 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 731 | bool NeonLayerSupport::IsConvertFp16ToFp32Supported(const TensorInfo& input, |
| 732 | const TensorInfo& output, |
| 733 | Optional<std::string&> reasonIfUnsupported) const |
| 734 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 735 | armnn::IgnoreUnused(input); |
| 736 | armnn::IgnoreUnused(output); |
| 737 | armnn::IgnoreUnused(reasonIfUnsupported); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 738 | return true; |
| 739 | } |
| 740 | |
Narumol Prangnawarat | 250d392 | 2020-03-30 16:11:04 +0100 | [diff] [blame] | 741 | bool NeonLayerSupport::IsConvertFp32ToBf16Supported(const TensorInfo& input, |
| 742 | const TensorInfo& output, |
| 743 | Optional<std::string&> reasonIfUnsupported) const |
| 744 | { |
| 745 | armnn::IgnoreUnused(input); |
| 746 | armnn::IgnoreUnused(output); |
| 747 | armnn::IgnoreUnused(reasonIfUnsupported); |
| 748 | return true; |
| 749 | } |
| 750 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 751 | bool NeonLayerSupport::IsConvertFp32ToFp16Supported(const TensorInfo& input, |
| 752 | const TensorInfo& output, |
| 753 | Optional<std::string&> reasonIfUnsupported) const |
| 754 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 755 | armnn::IgnoreUnused(input); |
| 756 | armnn::IgnoreUnused(output); |
| 757 | armnn::IgnoreUnused(reasonIfUnsupported); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 758 | return true; |
| 759 | } |
| 760 | |
| 761 | bool NeonLayerSupport::IsConvolution2dSupported(const TensorInfo& input, |
| 762 | const TensorInfo& output, |
| 763 | const Convolution2dDescriptor& descriptor, |
| 764 | const TensorInfo& weights, |
| 765 | const Optional<TensorInfo>& biases, |
| 766 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 767 | { |
Sadik Armagan | 045f6be | 2020-09-10 13:37:32 +0100 | [diff] [blame] | 768 | bool isFastMathEnabled = false; |
| 769 | #if defined(ARMCOMPUTENEON_ENABLED) |
| 770 | if (m_ModelContextPtr) |
| 771 | { |
| 772 | if (m_ModelContextPtr.get() != nullptr) |
| 773 | { |
Sadik Armagan | 04a7297 | 2020-09-14 15:44:18 +0100 | [diff] [blame] | 774 | auto modelOptions = dynamic_cast<NeonBackendModelContext*>(m_ModelContextPtr.get()); |
Sadik Armagan | 045f6be | 2020-09-10 13:37:32 +0100 | [diff] [blame] | 775 | if (modelOptions) |
| 776 | { |
| 777 | isFastMathEnabled = modelOptions->IsFastMathEnabled(); |
| 778 | } |
| 779 | } |
| 780 | } |
| 781 | #endif |
| 782 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 783 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonConvolution2dWorkloadValidate, |
| 784 | reasonIfUnsupported, |
| 785 | input, |
| 786 | output, |
| 787 | descriptor, |
| 788 | weights, |
Sadik Armagan | 045f6be | 2020-09-10 13:37:32 +0100 | [diff] [blame] | 789 | biases, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 790 | isFastMathEnabled, |
| 791 | nullptr); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 792 | } |
| 793 | |
Teresa Charlin | ec5f7d1 | 2021-10-22 17:15:00 +0100 | [diff] [blame] | 794 | bool NeonLayerSupport::IsConvolution3dSupported(const TensorInfo& input, |
| 795 | const TensorInfo& output, |
| 796 | const Convolution3dDescriptor& descriptor, |
| 797 | const TensorInfo& weights, |
| 798 | const Optional<TensorInfo>& biases, |
| 799 | Optional<std::string&> reasonIfUnsupported) const |
| 800 | { |
| 801 | bool isFastMathEnabled = false; |
| 802 | #if defined(ARMCOMPUTENEON_ENABLED) |
| 803 | if (m_ModelContextPtr) |
| 804 | { |
| 805 | if (m_ModelContextPtr.get() != nullptr) |
| 806 | { |
| 807 | auto modelOptions = dynamic_cast<NeonBackendModelContext*>(m_ModelContextPtr.get()); |
| 808 | if (modelOptions) |
| 809 | { |
| 810 | isFastMathEnabled = modelOptions->IsFastMathEnabled(); |
| 811 | } |
| 812 | } |
| 813 | } |
| 814 | #endif |
| 815 | |
| 816 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonConvolution3dWorkloadValidate, |
| 817 | reasonIfUnsupported, |
| 818 | input, |
| 819 | output, |
| 820 | descriptor, |
| 821 | weights, |
| 822 | biases, |
| 823 | isFastMathEnabled, |
| 824 | nullptr); |
| 825 | } |
| 826 | |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 827 | bool NeonLayerSupport::IsDepthToSpaceSupported(const TensorInfo& input, |
| 828 | const TensorInfo& output, |
| 829 | const DepthToSpaceDescriptor& descriptor, |
| 830 | Optional<std::string&> reasonIfUnsupported) const |
| 831 | { |
| 832 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonDepthToSpaceWorkloadValidate, |
| 833 | reasonIfUnsupported, |
| 834 | input, |
| 835 | output, |
| 836 | descriptor); |
| 837 | } |
| 838 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 839 | bool NeonLayerSupport::IsDepthwiseConvolutionSupported(const TensorInfo& input, |
| 840 | const TensorInfo& output, |
| 841 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 842 | const TensorInfo& weights, |
| 843 | const Optional<TensorInfo>& biases, |
| 844 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 845 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 846 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonDepthwiseConvolutionWorkloadValidate, |
| 847 | reasonIfUnsupported, |
| 848 | input, |
| 849 | output, |
| 850 | descriptor, |
| 851 | weights, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 852 | biases, |
| 853 | nullptr); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 854 | } |
| 855 | |
Narumol Prangnawarat | 01961a7 | 2019-05-30 16:47:12 +0100 | [diff] [blame] | 856 | bool NeonLayerSupport::IsDequantizeSupported(const TensorInfo& input, |
| 857 | const TensorInfo& output, |
| 858 | Optional<std::string&> reasonIfUnsupported) const |
| 859 | { |
| 860 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonDequantizeWorkloadValidate, |
| 861 | reasonIfUnsupported, |
| 862 | input, |
| 863 | output); |
| 864 | } |
| 865 | |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 866 | bool NeonLayerSupport::IsDilatedDepthwiseConvolutionSupported(const TensorInfo& input, |
| 867 | const TensorInfo& output, |
| 868 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 869 | const TensorInfo& weights, |
| 870 | const Optional<TensorInfo>& biases, |
| 871 | Optional<std::string&> reasonIfUnsupported) const |
| 872 | { |
| 873 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonDepthwiseConvolutionWorkloadValidate, |
| 874 | reasonIfUnsupported, |
| 875 | input, |
| 876 | output, |
| 877 | descriptor, |
| 878 | weights, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 879 | biases, |
| 880 | nullptr); |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 881 | } |
| 882 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 883 | bool NeonLayerSupport::IsElementwiseUnarySupported(const TensorInfo& input, |
| 884 | const TensorInfo& output, |
| 885 | const ElementwiseUnaryDescriptor& descriptor, |
| 886 | Optional<std::string&> reasonIfUnsupported) const |
| 887 | { |
Derek Lamberti | c77874a | 2020-04-28 13:34:56 +0100 | [diff] [blame] | 888 | switch(descriptor.m_Operation) |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 889 | { |
Derek Lamberti | c77874a | 2020-04-28 13:34:56 +0100 | [diff] [blame] | 890 | case UnaryOperation::Abs: |
| 891 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonAbsWorkloadValidate, |
| 892 | reasonIfUnsupported, |
| 893 | input, |
| 894 | output); |
| 895 | case UnaryOperation::Exp: |
| 896 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonExpWorkloadValidate, |
| 897 | reasonIfUnsupported, |
| 898 | input, |
| 899 | output); |
Teresa Charlin | 50de4fa | 2021-05-31 18:47:33 +0100 | [diff] [blame] | 900 | case UnaryOperation::LogicalNot: |
| 901 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonLogicalNotWorkloadValidate, |
| 902 | reasonIfUnsupported, |
| 903 | input, |
| 904 | output); |
| 905 | case UnaryOperation::Log: |
| 906 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonLogWorkloadValidate, |
| 907 | reasonIfUnsupported, |
| 908 | input, |
| 909 | output); |
Derek Lamberti | c77874a | 2020-04-28 13:34:56 +0100 | [diff] [blame] | 910 | case UnaryOperation::Neg: |
| 911 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonNegWorkloadValidate, |
| 912 | reasonIfUnsupported, |
| 913 | input, |
| 914 | output); |
| 915 | case UnaryOperation::Rsqrt: |
| 916 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonRsqrtWorkloadValidate, |
| 917 | reasonIfUnsupported, |
| 918 | input, |
| 919 | output); |
ryan.oshea3 | cff135b | 2021-10-07 15:28:14 +0000 | [diff] [blame] | 920 | case UnaryOperation::Sin: |
| 921 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSinWorkloadValidate, |
| 922 | reasonIfUnsupported, |
| 923 | input, |
| 924 | output); |
Derek Lamberti | c77874a | 2020-04-28 13:34:56 +0100 | [diff] [blame] | 925 | default: |
| 926 | return false; |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 927 | } |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 928 | } |
| 929 | |
Teresa Charlin | 4b10fef | 2020-07-29 09:36:41 +0100 | [diff] [blame] | 930 | bool NeonLayerSupport::IsFillSupported(const TensorInfo& input, |
| 931 | const TensorInfo& output, |
| 932 | const FillDescriptor& descriptor, |
| 933 | Optional<std::string&> reasonIfUnsupported) const |
Sadik Armagan | a792a05 | 2020-06-23 16:22:23 +0100 | [diff] [blame] | 934 | { |
Teresa Charlin | 4b10fef | 2020-07-29 09:36:41 +0100 | [diff] [blame] | 935 | armnn::IgnoreUnused(input); |
| 936 | armnn::IgnoreUnused(output); |
| 937 | armnn::IgnoreUnused(descriptor); |
| 938 | |
| 939 | return IsNeonBackendSupported(reasonIfUnsupported); |
Sadik Armagan | a792a05 | 2020-06-23 16:22:23 +0100 | [diff] [blame] | 940 | } |
| 941 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 942 | bool NeonLayerSupport::IsFloorSupported(const TensorInfo& input, |
| 943 | const TensorInfo& output, |
| 944 | Optional<std::string&> reasonIfUnsupported) const |
| 945 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 946 | armnn::IgnoreUnused(output); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 947 | return IsNeonBackendSupported(reasonIfUnsupported) && |
| 948 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 949 | input.GetDataType(), |
| 950 | &FalseFuncF16<>, |
| 951 | &TrueFunc<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 952 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 953 | &FalseFuncI32<>, |
| 954 | &FalseFuncU8<>); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 955 | } |
| 956 | |
| 957 | bool NeonLayerSupport::IsFullyConnectedSupported(const TensorInfo& input, |
| 958 | const TensorInfo& output, |
| 959 | const TensorInfo& weights, |
| 960 | const TensorInfo& biases, |
| 961 | const FullyConnectedDescriptor& descriptor, |
| 962 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 963 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 964 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonFullyConnectedWorkloadValidate, |
| 965 | reasonIfUnsupported, |
| 966 | input, |
| 967 | output, |
| 968 | weights, |
| 969 | biases, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 970 | descriptor, |
| 971 | nullptr); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 972 | } |
| 973 | |
Teresa Charlin | f540eb8 | 2020-04-10 19:24:55 +0100 | [diff] [blame] | 974 | bool NeonLayerSupport::IsGatherSupported(const TensorInfo& input0, |
| 975 | const TensorInfo& input1, |
| 976 | const TensorInfo& output, |
Teresa Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 977 | const GatherDescriptor& descriptor, |
Teresa Charlin | f540eb8 | 2020-04-10 19:24:55 +0100 | [diff] [blame] | 978 | Optional<std::string&> reasonIfUnsupported) const |
| 979 | { |
| 980 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonGatherWorkloadValidate, |
| 981 | reasonIfUnsupported, |
| 982 | input0, |
| 983 | input1, |
Teresa Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 984 | output, |
| 985 | descriptor); |
Teresa Charlin | f540eb8 | 2020-04-10 19:24:55 +0100 | [diff] [blame] | 986 | } |
| 987 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 988 | bool NeonLayerSupport::IsInputSupported(const TensorInfo& input, |
| 989 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 990 | { |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 991 | return IsNeonBackendSupported(reasonIfUnsupported, input); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 992 | } |
| 993 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 994 | bool NeonLayerSupport::IsInstanceNormalizationSupported(const TensorInfo& input, |
| 995 | const TensorInfo& output, |
| 996 | const InstanceNormalizationDescriptor& descriptor, |
| 997 | Optional<std::string&> reasonIfUnsupported) const |
| 998 | { |
| 999 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonInstanceNormalizationWorkloadValidate, |
| 1000 | reasonIfUnsupported, |
| 1001 | input, |
| 1002 | output, |
| 1003 | descriptor); |
| 1004 | } |
| 1005 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1006 | bool NeonLayerSupport::IsL2NormalizationSupported(const TensorInfo& input, |
| 1007 | const TensorInfo& output, |
| 1008 | const L2NormalizationDescriptor& descriptor, |
| 1009 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1010 | { |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 1011 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonL2NormalizationWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1012 | } |
| 1013 | |
James Conroy | 177df1e | 2020-11-13 10:18:51 +0000 | [diff] [blame] | 1014 | bool NeonLayerSupport::IsLogicalBinarySupported(const TensorInfo& input0, |
| 1015 | const TensorInfo& input1, |
| 1016 | const TensorInfo& output, |
| 1017 | const LogicalBinaryDescriptor& descriptor, |
| 1018 | Optional<std::string&> reasonIfUnsupported) const |
| 1019 | { |
| 1020 | switch(descriptor.m_Operation) |
| 1021 | { |
| 1022 | case LogicalBinaryOperation::LogicalAnd: |
| 1023 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonLogicalAndWorkloadValidate, |
| 1024 | reasonIfUnsupported, |
| 1025 | input0, |
| 1026 | input1, |
| 1027 | output); |
| 1028 | case LogicalBinaryOperation::LogicalOr: |
| 1029 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonLogicalOrWorkloadValidate, |
| 1030 | reasonIfUnsupported, |
| 1031 | input0, |
| 1032 | input1, |
| 1033 | output); |
| 1034 | default: |
| 1035 | return false; |
| 1036 | } |
| 1037 | } |
| 1038 | |
Keith Davis | 69e653f | 2020-07-02 11:49:26 +0100 | [diff] [blame] | 1039 | bool NeonLayerSupport::IsLogSoftmaxSupported(const TensorInfo& input, |
| 1040 | const TensorInfo& output, |
| 1041 | const LogSoftmaxDescriptor& descriptor, |
| 1042 | Optional<std::string&> reasonIfUnsupported) const |
| 1043 | { |
| 1044 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonLogSoftmaxWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 1045 | } |
| 1046 | |
Jan Eilers | ad5293a | 2019-07-08 09:57:55 +0100 | [diff] [blame] | 1047 | bool NeonLayerSupport::IsLstmSupported(const TensorInfo& input, |
| 1048 | const TensorInfo& outputStateIn, |
| 1049 | const TensorInfo& cellStateIn, |
| 1050 | const TensorInfo& scratchBuffer, |
| 1051 | const TensorInfo& outputStateOut, |
| 1052 | const TensorInfo& cellStateOut, |
| 1053 | const TensorInfo& output, |
| 1054 | const LstmDescriptor& descriptor, |
| 1055 | const LstmInputParamsInfo& paramsInfo, |
| 1056 | Optional<std::string&> reasonIfUnsupported) const |
| 1057 | { |
| 1058 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonLstmFloatWorkloadValidate, |
| 1059 | reasonIfUnsupported, |
| 1060 | input, |
| 1061 | outputStateIn, |
| 1062 | cellStateIn, |
| 1063 | scratchBuffer, |
| 1064 | outputStateOut, |
| 1065 | cellStateOut, |
| 1066 | output, |
| 1067 | descriptor, |
| 1068 | paramsInfo); |
| 1069 | } |
| 1070 | |
Nattapat Chaimanowong | 4e6597a | 2018-12-20 14:14:06 +0000 | [diff] [blame] | 1071 | bool NeonLayerSupport::IsMaximumSupported(const TensorInfo& input0, |
| 1072 | const TensorInfo& input1, |
| 1073 | const TensorInfo& output, |
| 1074 | Optional<std::string&> reasonIfUnsupported) const |
| 1075 | { |
| 1076 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMaximumWorkloadValidate, |
| 1077 | reasonIfUnsupported, |
| 1078 | input0, |
| 1079 | input1, |
| 1080 | output); |
| 1081 | } |
| 1082 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1083 | bool NeonLayerSupport::IsMeanSupported(const TensorInfo& input, |
| 1084 | const TensorInfo& output, |
| 1085 | const MeanDescriptor& descriptor, |
| 1086 | Optional<std::string&> reasonIfUnsupported) const |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 1087 | { |
Matthew Bentham | fd89996 | 2018-12-31 15:49:42 +0000 | [diff] [blame] | 1088 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMeanWorkloadValidate, |
| 1089 | reasonIfUnsupported, |
| 1090 | input, |
| 1091 | output, |
| 1092 | descriptor); |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 1093 | } |
| 1094 | |
Conor Kennedy | 54b2169 | 2019-01-09 07:57:38 +0000 | [diff] [blame] | 1095 | bool NeonLayerSupport::IsMinimumSupported(const TensorInfo& input0, |
| 1096 | const TensorInfo& input1, |
| 1097 | const TensorInfo& output, |
| 1098 | Optional<std::string&> reasonIfUnsupported) const |
| 1099 | { |
| 1100 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMinimumWorkloadValidate, |
| 1101 | reasonIfUnsupported, |
| 1102 | input0, |
| 1103 | input1, |
| 1104 | output); |
| 1105 | } |
| 1106 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1107 | bool NeonLayerSupport::IsMultiplicationSupported(const TensorInfo& input0, |
| 1108 | const TensorInfo& input1, |
| 1109 | const TensorInfo& output, |
| 1110 | Optional<std::string&> reasonIfUnsupported) const |
| 1111 | { |
| 1112 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMultiplicationWorkloadValidate, |
| 1113 | reasonIfUnsupported, |
| 1114 | input0, |
| 1115 | input1, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 1116 | output, |
| 1117 | nullptr); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1118 | } |
| 1119 | |
Pablo Tello | e61f071 | 2020-01-23 10:37:17 +0000 | [diff] [blame] | 1120 | bool NeonLayerSupport::IsDivisionSupported(const TensorInfo& input0, |
| 1121 | const TensorInfo& input1, |
| 1122 | const TensorInfo& output, |
| 1123 | Optional<std::string&> reasonIfUnsupported) const |
| 1124 | { |
| 1125 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonDivisionWorkloadValidate, |
| 1126 | reasonIfUnsupported, |
| 1127 | input0, |
| 1128 | input1, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 1129 | output, |
| 1130 | nullptr); |
Pablo Tello | e61f071 | 2020-01-23 10:37:17 +0000 | [diff] [blame] | 1131 | } |
| 1132 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1133 | bool NeonLayerSupport::IsNormalizationSupported(const TensorInfo& input, |
| 1134 | const TensorInfo& output, |
| 1135 | const NormalizationDescriptor& descriptor, |
| 1136 | Optional<std::string&> reasonIfUnsupported) const |
| 1137 | { |
| 1138 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonNormalizationWorkloadValidate, |
| 1139 | reasonIfUnsupported, |
| 1140 | input, |
| 1141 | output, |
| 1142 | descriptor); |
| 1143 | } |
| 1144 | |
| 1145 | bool NeonLayerSupport::IsOutputSupported(const TensorInfo& output, |
| 1146 | Optional<std::string&> reasonIfUnsupported) const |
| 1147 | { |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 1148 | return IsNeonBackendSupported(reasonIfUnsupported, output); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1149 | } |
| 1150 | |
Éanna Ó Catháin | 1205574 | 2019-01-25 10:01:40 +0000 | [diff] [blame] | 1151 | bool NeonLayerSupport::IsPadSupported(const TensorInfo& input, |
| 1152 | const TensorInfo& output, |
| 1153 | const PadDescriptor& descriptor, |
| 1154 | Optional<std::string&> reasonIfUnsupported) const |
| 1155 | { |
| 1156 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonPadWorkloadValidate, |
| 1157 | reasonIfUnsupported, |
| 1158 | input, |
| 1159 | output, |
| 1160 | descriptor); |
| 1161 | } |
| 1162 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1163 | bool NeonLayerSupport::IsPermuteSupported(const TensorInfo& input, |
| 1164 | const TensorInfo& output, |
| 1165 | const PermuteDescriptor& descriptor, |
| 1166 | Optional<std::string&> reasonIfUnsupported) const |
| 1167 | { |
| 1168 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonPermuteWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1169 | } |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1170 | |
| 1171 | bool NeonLayerSupport::IsPooling2dSupported(const TensorInfo& input, |
| 1172 | const TensorInfo& output, |
| 1173 | const Pooling2dDescriptor& descriptor, |
| 1174 | Optional<std::string&> reasonIfUnsupported) const |
| 1175 | { |
| 1176 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonPooling2dWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 1177 | } |
| 1178 | |
Nikhil Raj | 9b46148 | 2019-07-03 15:58:31 +0100 | [diff] [blame] | 1179 | bool NeonLayerSupport::IsPreluSupported(const armnn::TensorInfo &input, |
| 1180 | const armnn::TensorInfo &alpha, |
| 1181 | const armnn::TensorInfo &output, |
| 1182 | armnn::Optional<std::string &> reasonIfUnsupported) const |
| 1183 | { |
| 1184 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonPreluWorkloadValidate, reasonIfUnsupported, input, alpha, output); |
| 1185 | } |
| 1186 | |
James Conroy | cc34093 | 2020-05-12 18:08:52 +0100 | [diff] [blame] | 1187 | bool NeonLayerSupport::IsQLstmSupported(const TensorInfo& input, |
| 1188 | const TensorInfo& previousOutputIn, |
| 1189 | const TensorInfo& previousCellStateIn, |
| 1190 | const TensorInfo& outputStateOut, |
| 1191 | const TensorInfo& cellStateOut, |
| 1192 | const TensorInfo& output, |
| 1193 | const QLstmDescriptor& descriptor, |
| 1194 | const LstmInputParamsInfo& paramsInfo, |
| 1195 | Optional<std::string&> reasonIfUnsupported) const |
| 1196 | { |
| 1197 | // Check required here in order to pass IsLayerSupported for datatypes tests |
| 1198 | if (input.GetDataType() == armnn::DataType::QAsymmS8 && |
| 1199 | previousOutputIn.GetDataType() == armnn::DataType::QAsymmS8 && |
| 1200 | previousCellStateIn.GetDataType() == armnn::DataType::QSymmS16 && |
| 1201 | outputStateOut.GetDataType() == armnn::DataType::QAsymmS8 && |
| 1202 | cellStateOut.GetDataType() == armnn::DataType::QSymmS16 && |
| 1203 | output.GetDataType() == armnn::DataType::QAsymmS8) |
| 1204 | { |
| 1205 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonQLstmWorkloadValidate, |
| 1206 | reasonIfUnsupported, |
| 1207 | input, |
| 1208 | previousCellStateIn, |
| 1209 | previousOutputIn, |
| 1210 | cellStateOut, |
| 1211 | outputStateOut, |
| 1212 | output, |
| 1213 | descriptor, |
| 1214 | paramsInfo); |
| 1215 | } |
| 1216 | else |
| 1217 | { |
| 1218 | return false; |
| 1219 | } |
| 1220 | } |
| 1221 | |
Sadik Armagan | fabc289 | 2019-05-31 09:05:11 +0100 | [diff] [blame] | 1222 | bool NeonLayerSupport::IsQuantizeSupported(const TensorInfo& input, |
| 1223 | const TensorInfo& output, |
| 1224 | Optional<std::string&> reasonIfUnsupported) const |
| 1225 | { |
| 1226 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonQuantizeWorkloadValidate, |
| 1227 | reasonIfUnsupported, |
| 1228 | input, |
| 1229 | output); |
| 1230 | } |
| 1231 | |
Francis Murtagh | 4fc3c48 | 2019-08-02 13:20:54 +0100 | [diff] [blame] | 1232 | bool NeonLayerSupport::IsQuantizedLstmSupported(const TensorInfo& input, |
| 1233 | const TensorInfo& cellStateIn, |
| 1234 | const TensorInfo& outputStateIn, |
| 1235 | const TensorInfo& cellStateOut, |
| 1236 | const TensorInfo& outputStateOut, |
| 1237 | const QuantizedLstmInputParamsInfo& paramsInfo, |
| 1238 | Optional<std::string&> reasonIfUnsupported) const |
| 1239 | { |
| 1240 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonQuantizedLstmWorkloadValidate, |
| 1241 | reasonIfUnsupported, |
| 1242 | input, |
| 1243 | cellStateIn, |
| 1244 | outputStateIn, |
| 1245 | cellStateOut, |
| 1246 | outputStateOut, |
| 1247 | paramsInfo); |
| 1248 | } |
| 1249 | |
Sadik Armagan | a274748 | 2021-02-09 10:28:54 +0000 | [diff] [blame] | 1250 | bool NeonLayerSupport::IsReduceSupported(const TensorInfo& input, |
| 1251 | const TensorInfo& output, |
| 1252 | const ReduceDescriptor& descriptor, |
| 1253 | Optional<std::string&> reasonIfUnsupported) const |
| 1254 | { |
| 1255 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonReduceWorkloadValidate, |
| 1256 | reasonIfUnsupported, |
| 1257 | input, |
| 1258 | output, |
| 1259 | descriptor); |
| 1260 | } |
| 1261 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1262 | bool NeonLayerSupport::IsReshapeSupported(const TensorInfo& input, |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 1263 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1264 | const ReshapeDescriptor& descriptor, |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1265 | Optional<std::string&> reasonIfUnsupported) const |
| 1266 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1267 | armnn::IgnoreUnused(descriptor); |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 1268 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonReshapeWorkloadValidate, |
| 1269 | reasonIfUnsupported, |
| 1270 | input, |
| 1271 | output); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1272 | } |
| 1273 | |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 1274 | bool NeonLayerSupport::IsResizeSupported(const TensorInfo& input, |
| 1275 | const TensorInfo& output, |
| 1276 | const ResizeDescriptor& descriptor, |
| 1277 | Optional<std::string&> reasonIfUnsupported) const |
| 1278 | { |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 1279 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonResizeWorkloadValidate, |
| 1280 | reasonIfUnsupported, |
| 1281 | input, |
| 1282 | output, |
| 1283 | descriptor); |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 1284 | } |
| 1285 | |
josh minor | 036f02d | 2019-11-15 14:53:22 -0600 | [diff] [blame] | 1286 | bool NeonLayerSupport::IsSliceSupported(const TensorInfo& input, |
| 1287 | const TensorInfo& output, |
| 1288 | const SliceDescriptor& descriptor, |
| 1289 | Optional<std::string&> reasonIfUnsupported) const |
| 1290 | { |
| 1291 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSliceWorkloadValidate, |
| 1292 | reasonIfUnsupported, |
| 1293 | input, |
| 1294 | output, |
| 1295 | descriptor); |
| 1296 | } |
| 1297 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1298 | bool NeonLayerSupport::IsSoftmaxSupported(const TensorInfo& input, |
| 1299 | const TensorInfo& output, |
| 1300 | const SoftmaxDescriptor& descriptor, |
| 1301 | Optional<std::string&> reasonIfUnsupported) const |
| 1302 | { |
| 1303 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSoftmaxWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 1304 | } |
| 1305 | |
Mike Kelly | 0be3a88 | 2020-01-24 11:27:50 +0000 | [diff] [blame] | 1306 | bool NeonLayerSupport::IsSpaceToBatchNdSupported(const TensorInfo& input, |
| 1307 | const TensorInfo& output, |
| 1308 | const SpaceToBatchNdDescriptor& descriptor, |
| 1309 | Optional<std::string&> reasonIfUnsupported) const |
| 1310 | { |
| 1311 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSpaceToBatchNdWorkloadValidate, |
| 1312 | reasonIfUnsupported, |
| 1313 | input, |
| 1314 | output, |
| 1315 | descriptor); |
| 1316 | } |
| 1317 | |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 1318 | bool NeonLayerSupport::IsSpaceToDepthSupported(const TensorInfo& input, |
Mike Kelly | 0be3a88 | 2020-01-24 11:27:50 +0000 | [diff] [blame] | 1319 | const TensorInfo& output, |
| 1320 | const SpaceToDepthDescriptor& descriptor, |
| 1321 | Optional<std::string&> reasonIfUnsupported) const |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 1322 | { |
| 1323 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSpaceToDepthWorkloadValidate, |
| 1324 | reasonIfUnsupported, |
| 1325 | input, |
| 1326 | output, |
| 1327 | descriptor); |
| 1328 | } |
| 1329 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1330 | bool NeonLayerSupport::IsSplitterSupported(const TensorInfo& input, |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 1331 | const std::vector<std::reference_wrapper<TensorInfo>>& outputs, |
| 1332 | const ViewsDescriptor& descriptor, |
| 1333 | Optional<std::string&> reasonIfUnsupported) const |
| 1334 | { |
| 1335 | #if defined(ARMCOMPUTENEON_ENABLED) |
| 1336 | // Split along the last dimension, cannot use sub-tensors |
| 1337 | // as width and height of the sub-tensors do not match |
| 1338 | // the width and height of the parent tensor |
| 1339 | // in case of input with more than 2D. |
| 1340 | std::set<unsigned int> splitAxis = ComputeSplitAxis(descriptor, input.GetShape()); |
| 1341 | if (descriptor.GetNumDimensions() > 2 && splitAxis.size() == 1 && |
| 1342 | *splitAxis.begin() == descriptor.GetNumDimensions() - 1 ) |
| 1343 | { |
| 1344 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSplitterWorkloadValidate, |
| 1345 | reasonIfUnsupported, |
| 1346 | input, |
| 1347 | outputs, |
| 1348 | *splitAxis.begin()); |
| 1349 | } |
| 1350 | #endif |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1351 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 1352 | for (auto output : outputs) |
| 1353 | { |
| 1354 | if (!input.IsTypeSpaceMatch(output)) // Cannot use sub-tensors if the types are not same space |
| 1355 | { |
| 1356 | SetValueChecked(reasonIfUnsupported, "Neon Splitter: Types and quantization parameters must match."); |
| 1357 | return false; |
| 1358 | } |
| 1359 | } |
| 1360 | return true; |
| 1361 | } |
| 1362 | |
Matthew Jackson | 87f65ea | 2019-08-01 10:01:34 +0100 | [diff] [blame] | 1363 | bool NeonLayerSupport::IsStackSupported(const std::vector<const TensorInfo*>& inputs, |
| 1364 | const TensorInfo& output, |
| 1365 | const StackDescriptor& descriptor, |
| 1366 | Optional<std::string&> reasonIfUnsupported) const |
| 1367 | { |
| 1368 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonStackWorkloadValidate, |
| 1369 | reasonIfUnsupported, |
| 1370 | inputs, |
| 1371 | output, |
| 1372 | descriptor); |
| 1373 | } |
| 1374 | |
FinnWilliamsArm | 1fa1919 | 2019-08-02 17:26:31 +0100 | [diff] [blame] | 1375 | bool NeonLayerSupport::IsStridedSliceSupported(const TensorInfo& input, |
| 1376 | const TensorInfo& output, |
| 1377 | const StridedSliceDescriptor& descriptor, |
| 1378 | Optional<std::string&> reasonIfUnsupported) const |
| 1379 | { |
| 1380 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonStridedSliceWorkloadValidate, |
| 1381 | reasonIfUnsupported, |
| 1382 | input, |
| 1383 | output, |
| 1384 | descriptor); |
| 1385 | } |
| 1386 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1387 | bool NeonLayerSupport::IsSubtractionSupported(const TensorInfo& input0, |
| 1388 | const TensorInfo& input1, |
| 1389 | const TensorInfo& output, |
| 1390 | Optional<std::string&> reasonIfUnsupported) const |
| 1391 | { |
| 1392 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSubtractionWorkloadValidate, |
| 1393 | reasonIfUnsupported, |
| 1394 | input0, |
| 1395 | input1, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 1396 | output, |
| 1397 | nullptr); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1398 | } |
| 1399 | |
Sadik Armagan | 581742d | 2019-08-12 14:11:37 +0100 | [diff] [blame] | 1400 | bool NeonLayerSupport::IsTransposeConvolution2dSupported(const TensorInfo& input, |
| 1401 | const TensorInfo& output, |
| 1402 | const TransposeConvolution2dDescriptor& descriptor, |
| 1403 | const TensorInfo& weights, |
| 1404 | const Optional<TensorInfo>& biases, |
| 1405 | Optional<std::string&> reasonIfUnsupported) const |
| 1406 | { |
| 1407 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonTransposeConvolution2dWorkloadValidate, |
| 1408 | reasonIfUnsupported, |
| 1409 | input, |
| 1410 | output, |
| 1411 | descriptor, |
| 1412 | weights, |
| 1413 | biases); |
| 1414 | } |
| 1415 | |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 1416 | bool NeonLayerSupport::IsTransposeSupported(const TensorInfo& input, |
| 1417 | const TensorInfo& output, |
| 1418 | const TransposeDescriptor& descriptor, |
| 1419 | Optional<std::string&> reasonIfUnsupported) const |
| 1420 | { |
| 1421 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonTransposeWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 1422 | } |
| 1423 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 1424 | } // namespace armnn |