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