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