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