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