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