telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. 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" |
arovir01 | 7c22c70 | 2018-10-09 11:16:46 +0100 | [diff] [blame] | 8 | |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 9 | #include <armnn/utility/IgnoreUnused.hpp> |
David Beck | 3cc9a62 | 2018-10-12 10:38:31 +0100 | [diff] [blame] | 10 | #include <armnn/Descriptors.hpp> |
Matteo Martincigh | c601aa6 | 2019-10-29 15:03:22 +0000 | [diff] [blame] | 11 | #include <armnn/BackendRegistry.hpp> |
| 12 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 13 | #include <InternalTypes.hpp> |
| 14 | #include <LayerSupportCommon.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 15 | |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 16 | #if defined(ARMCOMPUTECL_ENABLED) |
Narumol Prangnawarat | 7413583 | 2019-05-23 15:07:33 +0100 | [diff] [blame] | 17 | #include <aclCommon/ArmComputeUtils.hpp> |
Aron Virginas-Tar | 710f664 | 2019-11-27 14:48:32 +0000 | [diff] [blame] | 18 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
Aron Virginas-Tar | 8204694 | 2019-09-09 15:18:29 +0100 | [diff] [blame] | 19 | #include "workloads/ClAbsWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 20 | #include "workloads/ClAdditionWorkload.hpp" |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 21 | #include "workloads/ClActivationWorkload.hpp" |
James Conroy | 2dc0572 | 2019-09-19 17:00:31 +0100 | [diff] [blame] | 22 | #include "workloads/ClArgMinMaxWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 23 | #include "workloads/ClBatchNormalizationFloatWorkload.hpp" |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 24 | #include "workloads/ClBatchToSpaceNdWorkload.hpp" |
Teresa Charlin | 2b030d9 | 2020-03-27 16:40:56 +0000 | [diff] [blame] | 25 | #include "workloads/ClComparisonWorkload.hpp" |
Mike Kelly | 0886ac4 | 2020-04-27 09:55:40 +0100 | [diff] [blame] | 26 | #include "workloads/ClConstantWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 27 | #include "workloads/ClConvertFp16ToFp32Workload.hpp" |
| 28 | #include "workloads/ClConvertFp32ToFp16Workload.hpp" |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 29 | #include "workloads/ClConvolution2dWorkload.hpp" |
Aron Virginas-Tar | b280196 | 2019-09-30 11:24:53 +0100 | [diff] [blame] | 30 | #include "workloads/ClDepthToSpaceWorkload.hpp" |
Matthew Bentham | d877739 | 2018-10-08 09:38:55 +0100 | [diff] [blame] | 31 | #include "workloads/ClDepthwiseConvolutionWorkload.hpp" |
Aron Virginas-Tar | b280196 | 2019-09-30 11:24:53 +0100 | [diff] [blame] | 32 | #include "workloads/ClDequantizeWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 33 | #include "workloads/ClDivisionFloatWorkload.hpp" |
Sadik Armagan | 9fabf43 | 2020-05-27 13:40:58 +0100 | [diff] [blame] | 34 | #include "workloads/ClExpWorkload.hpp" |
Sadik Armagan | 9be4916 | 2019-10-30 16:15:26 +0000 | [diff] [blame] | 35 | #include "workloads/ClFloorFloatWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 36 | #include "workloads/ClFullyConnectedWorkload.hpp" |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame^] | 37 | #include "workloads/ClGatherWorkload.hpp" |
Aron Virginas-Tar | 8168f40 | 2019-10-04 13:10:16 +0100 | [diff] [blame] | 38 | #include "workloads/ClInstanceNormalizationWorkload.hpp" |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 39 | #include "workloads/ClL2NormalizationFloatWorkload.hpp" |
| 40 | #include "workloads/ClLstmFloatWorkload.hpp" |
keidav01 | a959ee5 | 2018-12-19 10:04:58 +0000 | [diff] [blame] | 41 | #include "workloads/ClMaximumWorkload.hpp" |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 42 | #include "workloads/ClMeanWorkload.hpp" |
Jim Flynn | 6905941 | 2019-05-17 13:03:57 +0100 | [diff] [blame] | 43 | #include "workloads/ClConcatWorkload.hpp" |
saoste01 | 9292aa3 | 2019-01-08 13:55:59 +0000 | [diff] [blame] | 44 | #include "workloads/ClMinimumWorkload.hpp" |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 45 | #include "workloads/ClMultiplicationWorkload.hpp" |
Sadik Armagan | ac47210 | 2020-03-24 09:54:36 +0000 | [diff] [blame] | 46 | #include "workloads/ClNegWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 47 | #include "workloads/ClNormalizationFloatWorkload.hpp" |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 48 | #include "workloads/ClPadWorkload.hpp" |
| 49 | #include "workloads/ClPermuteWorkload.hpp" |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 50 | #include "workloads/ClPooling2dWorkload.hpp" |
Nikhil Raj | 91e4c6d | 2019-07-05 12:22:58 +0100 | [diff] [blame] | 51 | #include "workloads/ClPreluWorkload.hpp" |
Ryan OShea | 2323af4 | 2020-05-13 16:36:19 +0100 | [diff] [blame] | 52 | #include "workloads/ClQLstmWorkload.hpp" |
| 53 | #include "workloads/ClQuantizedLstmWorkload.hpp" |
| 54 | #include "workloads/ClQuantizeWorkload.hpp" |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 55 | #include "workloads/ClReshapeWorkload.hpp" |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 56 | #include "workloads/ClResizeWorkload.hpp" |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 57 | #include "workloads/ClRsqrtWorkload.hpp" |
Aron Virginas-Tar | 94c4fef | 2019-11-25 15:37:08 +0000 | [diff] [blame] | 58 | #include "workloads/ClSliceWorkload.hpp" |
Teresa Charlin | c1f6b09 | 2020-05-11 16:10:38 +0100 | [diff] [blame] | 59 | #include "workloads/ClSoftmaxWorkload.hpp" |
Sadik Armagan | f446432 | 2018-12-20 16:19:12 +0000 | [diff] [blame] | 60 | #include "workloads/ClSpaceToBatchNdWorkload.hpp" |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 61 | #include "workloads/ClSpaceToDepthWorkload.hpp" |
Narumol Prangnawarat | 7413583 | 2019-05-23 15:07:33 +0100 | [diff] [blame] | 62 | #include "workloads/ClSplitterWorkload.hpp" |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 63 | #include "workloads/ClStackWorkload.hpp" |
keidav01 | d74dc91 | 2018-12-10 18:16:07 +0000 | [diff] [blame] | 64 | #include "workloads/ClStridedSliceWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 65 | #include "workloads/ClSubtractionWorkload.hpp" |
Aron Virginas-Tar | 7a3e2fe | 2019-06-27 18:54:47 +0100 | [diff] [blame] | 66 | #include "workloads/ClTransposeConvolution2dWorkload.hpp" |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 67 | #include "workloads/ClTransposeWorkload.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 68 | #endif |
| 69 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 70 | |
| 71 | namespace armnn |
| 72 | { |
arovir01 | 7c22c70 | 2018-10-09 11:16:46 +0100 | [diff] [blame] | 73 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 74 | namespace |
| 75 | { |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 76 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 77 | template<unsigned int FilterSize> |
| 78 | bool IsMatchingSize2d(const TensorInfo& weightInfo) |
| 79 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 80 | // Width & Height must match. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 81 | return (weightInfo.GetShape()[3] == FilterSize) && (weightInfo.GetShape()[2] == FilterSize); |
| 82 | } |
| 83 | |
| 84 | template<uint32_t ValidStride> |
| 85 | bool IsMatchingStride(uint32_t actualStride) |
| 86 | { |
| 87 | return ValidStride == actualStride; |
| 88 | } |
| 89 | |
| 90 | template<uint32_t FirstStride, uint32_t SecondStride, uint32_t... ValidStrides> |
| 91 | bool IsMatchingStride(uint32_t actualStride) |
| 92 | { |
| 93 | return IsMatchingStride<FirstStride>(actualStride) || IsMatchingStride<SecondStride, ValidStrides...>(actualStride); |
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 | |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 96 | template<typename ... Args> |
| 97 | bool IsClBackendSupported(Optional<std::string&> reasonIfUnsupported, Args... args) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 98 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 99 | IgnoreUnused(reasonIfUnsupported, (args)...); |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 100 | #if defined(ARMCOMPUTECL_ENABLED) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 101 | return true; |
| 102 | #else |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 103 | if (reasonIfUnsupported) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 104 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 105 | reasonIfUnsupported.value() = "The armnn library has been built without CL support"; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 106 | } |
| 107 | return false; |
| 108 | #endif |
| 109 | } |
| 110 | |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 111 | #if defined(ARMCOMPUTECL_ENABLED) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 112 | #define FORWARD_CL_LAYER_SUPPORT_FUNC(expr) (expr) |
| 113 | #else |
| 114 | #define FORWARD_CL_LAYER_SUPPORT_FUNC(expr) IsClBackendSupported(reasonIfUnsupported) |
| 115 | #endif |
| 116 | |
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 | template<class FuncType, class... Args> |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 119 | inline bool IsWorkloadSupported(FuncType&& func, Optional<std::string&> reasonIfUnsupported, Args&&... args) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 120 | { |
| 121 | arm_compute::Status aclStatus = func(std::forward<Args>(args)...); |
| 122 | const bool supported = (aclStatus.error_code() == arm_compute::ErrorCode::OK); |
| 123 | if (!supported && reasonIfUnsupported) |
| 124 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 125 | reasonIfUnsupported.value() = aclStatus.error_description(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 126 | } |
| 127 | return supported; |
| 128 | } |
| 129 | |
| 130 | #define FORWARD_WORKLOAD_VALIDATE_FUNC(func, reasonIfUnsupported, ...) \ |
| 131 | return IsWorkloadSupported(func, reasonIfUnsupported, __VA_ARGS__); |
| 132 | #else |
| 133 | #define FORWARD_WORKLOAD_VALIDATE_FUNC(func, reasonIfUnsupported, ...) \ |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 134 | return IsClBackendSupported(reasonIfUnsupported, __VA_ARGS__); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 135 | #endif |
| 136 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 137 | template<typename FloatFunc, typename Uint8Func, typename ... Params> |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 138 | bool IsSupportedForDataTypeCl(Optional<std::string&> reasonIfUnsupported, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 139 | DataType dataType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 140 | FloatFunc floatFuncPtr, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 141 | Uint8Func uint8FuncPtr, |
| 142 | Params&&... params) |
| 143 | { |
| 144 | return IsClBackendSupported(reasonIfUnsupported) && |
| 145 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 146 | dataType, |
| 147 | floatFuncPtr, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 148 | floatFuncPtr, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 149 | uint8FuncPtr, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 150 | &FalseFunc<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 151 | &FalseFunc<>, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 152 | std::forward<Params>(params)...); |
| 153 | } |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 154 | } // anonymous namespace |
| 155 | |
Aron Virginas-Tar | 8204694 | 2019-09-09 15:18:29 +0100 | [diff] [blame] | 156 | bool ClLayerSupport::IsAbsSupported(const TensorInfo& input, |
| 157 | const TensorInfo& output, |
| 158 | Optional<std::string&> reasonIfUnsupported) const |
| 159 | { |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 160 | ElementwiseUnaryDescriptor descriptor(UnaryOperation::Abs); |
| 161 | return IsElementwiseUnarySupported(input, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | 8204694 | 2019-09-09 15:18:29 +0100 | [diff] [blame] | 162 | } |
| 163 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 164 | bool ClLayerSupport::IsActivationSupported(const TensorInfo& input, |
| 165 | const TensorInfo& output, |
| 166 | const ActivationDescriptor& descriptor, |
| 167 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 168 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 169 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClActivationWorkloadValidate, |
| 170 | reasonIfUnsupported, |
| 171 | input, |
| 172 | output, |
| 173 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 174 | } |
| 175 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 176 | bool ClLayerSupport::IsAdditionSupported(const TensorInfo& input0, |
| 177 | const TensorInfo& input1, |
| 178 | const TensorInfo& output, |
| 179 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 180 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 181 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClAdditionValidate, |
| 182 | reasonIfUnsupported, |
| 183 | input0, |
| 184 | input1, |
| 185 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 186 | } |
| 187 | |
James Conroy | 2dc0572 | 2019-09-19 17:00:31 +0100 | [diff] [blame] | 188 | bool ClLayerSupport::IsArgMinMaxSupported(const TensorInfo& input, |
| 189 | const TensorInfo& output, |
| 190 | const ArgMinMaxDescriptor& descriptor, |
| 191 | Optional<std::string&> reasonIfUnsupported) const |
| 192 | { |
Francis Murtagh | 52ec346 | 2019-11-19 12:24:19 +0000 | [diff] [blame] | 193 | |
James Conroy | 2dc0572 | 2019-09-19 17:00:31 +0100 | [diff] [blame] | 194 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClArgMinMaxWorkloadValidate, |
| 195 | reasonIfUnsupported, |
| 196 | input, |
| 197 | output, |
| 198 | descriptor); |
| 199 | } |
| 200 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 201 | bool ClLayerSupport::IsBatchNormalizationSupported(const TensorInfo& input, |
| 202 | const TensorInfo& output, |
| 203 | const TensorInfo& mean, |
| 204 | const TensorInfo& var, |
| 205 | const TensorInfo& beta, |
| 206 | const TensorInfo& gamma, |
| 207 | const BatchNormalizationDescriptor& descriptor, |
| 208 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 209 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 210 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClBatchNormalizationValidate, |
| 211 | reasonIfUnsupported, |
| 212 | input, |
| 213 | output, |
| 214 | mean, |
| 215 | var, |
| 216 | beta, |
| 217 | gamma, |
| 218 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 219 | } |
| 220 | |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 221 | bool ClLayerSupport::IsBatchToSpaceNdSupported(const TensorInfo& input, |
| 222 | const TensorInfo& output, |
| 223 | const BatchToSpaceNdDescriptor& descriptor, |
| 224 | Optional<std::string&> reasonIfUnsupported) const |
| 225 | { |
| 226 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClBatchToSpaceNdWorkloadValidate, |
| 227 | reasonIfUnsupported, |
| 228 | input, |
| 229 | output, |
| 230 | descriptor); |
| 231 | } |
| 232 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 233 | bool ClLayerSupport::IsComparisonSupported(const TensorInfo& input0, |
| 234 | const TensorInfo& input1, |
| 235 | const TensorInfo& output, |
| 236 | const ComparisonDescriptor& descriptor, |
| 237 | Optional<std::string&> reasonIfUnsupported) const |
| 238 | { |
Teresa Charlin | 2b030d9 | 2020-03-27 16:40:56 +0000 | [diff] [blame] | 239 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClComparisonWorkloadValidate, |
| 240 | reasonIfUnsupported, |
| 241 | input0, |
| 242 | input1, |
| 243 | output, |
| 244 | descriptor); |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 245 | } |
| 246 | |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 247 | bool ClLayerSupport::IsConcatSupported(const std::vector<const TensorInfo*> inputs, |
| 248 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 249 | const ConcatDescriptor& descriptor, |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 250 | Optional<std::string&> reasonIfUnsupported) const |
| 251 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 252 | if (descriptor.GetNumDimensions() <= descriptor.GetConcatAxis()) |
| 253 | { |
| 254 | SetValueChecked(reasonIfUnsupported, "Cl Concat: Concat axis > Number of dimensions."); |
| 255 | return false; |
| 256 | } |
| 257 | |
| 258 | unsigned int concatInnerAxis = (descriptor.GetNumDimensions() - descriptor.GetConcatAxis()) - 1; |
| 259 | if(concatInnerAxis < 3) // Width, height, or channels |
| 260 | { |
| 261 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConcatWorkloadValidate, |
| 262 | reasonIfUnsupported, |
| 263 | inputs, |
| 264 | output, |
| 265 | descriptor); |
| 266 | } |
| 267 | else if (concatInnerAxis == 3) |
| 268 | { |
| 269 | // We rely on the sub-tensor optimization to handle the batch dimension for 4D tensors. If we can't use |
| 270 | // sub-tensors for this then we can't support it. Here is where we check that the sub-tensors will work. |
| 271 | for (auto& input : inputs) |
| 272 | { |
| 273 | if (input && !output.IsTypeSpaceMatch(*input)) // Cannot use sub-tensors if the types are not same space |
| 274 | { |
| 275 | SetValueChecked(reasonIfUnsupported, "Cl Concat: Types and quantization parameters must match."); |
| 276 | return false; |
| 277 | } |
| 278 | } |
| 279 | return true; // Sub-tensors support concat along batch |
| 280 | } |
| 281 | else // > 4 dimensions not supported. |
| 282 | { |
| 283 | SetValueChecked(reasonIfUnsupported, "Cl Concat: Maximum of 4 dimensions supported."); |
| 284 | return false; |
| 285 | } |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 286 | } |
| 287 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 288 | bool ClLayerSupport::IsConstantSupported(const TensorInfo& output, |
| 289 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 290 | { |
Mike Kelly | 0886ac4 | 2020-04-27 09:55:40 +0100 | [diff] [blame] | 291 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConstantWorkloadValidate, |
| 292 | reasonIfUnsupported, |
| 293 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 294 | } |
| 295 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 296 | bool ClLayerSupport::IsConvertFp16ToFp32Supported(const TensorInfo& input, |
| 297 | const TensorInfo& output, |
| 298 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 299 | { |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 300 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConvertFp16ToFp32WorkloadValidate, |
| 301 | reasonIfUnsupported, |
| 302 | input, |
| 303 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 304 | } |
| 305 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 306 | bool ClLayerSupport::IsConvertFp32ToFp16Supported(const TensorInfo& input, |
| 307 | const TensorInfo& output, |
| 308 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 309 | { |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 310 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConvertFp32ToFp16WorkloadValidate, |
| 311 | reasonIfUnsupported, |
| 312 | input, |
| 313 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 314 | } |
| 315 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 316 | bool ClLayerSupport::IsConvolution2dSupported(const TensorInfo& input, |
| 317 | const TensorInfo& output, |
| 318 | const Convolution2dDescriptor& descriptor, |
| 319 | const TensorInfo& weights, |
| 320 | const Optional<TensorInfo>& biases, |
| 321 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 322 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 323 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConvolution2dWorkloadValidate, |
| 324 | reasonIfUnsupported, |
| 325 | input, |
| 326 | output, |
| 327 | descriptor, |
| 328 | weights, |
| 329 | biases); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 330 | } |
| 331 | |
Jim Flynn | 983daec | 2019-05-29 16:20:16 +0100 | [diff] [blame] | 332 | bool ClLayerSupport::IsDequantizeSupported(const TensorInfo& input, |
| 333 | const TensorInfo& output, |
| 334 | Optional<std::string&> reasonIfUnsupported) const |
| 335 | { |
| 336 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDequantizeWorkloadValidate, |
| 337 | reasonIfUnsupported, |
| 338 | input, |
| 339 | output); |
| 340 | } |
| 341 | |
Aron Virginas-Tar | b280196 | 2019-09-30 11:24:53 +0100 | [diff] [blame] | 342 | bool ClLayerSupport::IsDepthToSpaceSupported(const TensorInfo& input, |
| 343 | const TensorInfo& output, |
| 344 | const DepthToSpaceDescriptor& descriptor, |
| 345 | Optional<std::string&> reasonIfUnsupported) const |
| 346 | { |
| 347 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDepthToSpaceWorkloadValidate, |
| 348 | reasonIfUnsupported, |
| 349 | input, |
| 350 | output, |
| 351 | descriptor); |
| 352 | } |
| 353 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 354 | bool ClLayerSupport::IsDepthwiseConvolutionSupported(const TensorInfo& input, |
| 355 | const TensorInfo& output, |
| 356 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 357 | const TensorInfo& weights, |
| 358 | const Optional<TensorInfo>& biases, |
| 359 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 360 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 361 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDepthwiseConvolutionWorkloadValidate, |
| 362 | reasonIfUnsupported, |
| 363 | input, |
| 364 | output, |
| 365 | descriptor, |
| 366 | weights, |
| 367 | biases); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 368 | } |
| 369 | |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 370 | bool ClLayerSupport::IsDilatedDepthwiseConvolutionSupported(const TensorInfo& input, |
| 371 | const TensorInfo& output, |
| 372 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 373 | const TensorInfo& weights, |
| 374 | const Optional<TensorInfo>& biases, |
| 375 | Optional<std::string&> reasonIfUnsupported) const |
| 376 | { |
| 377 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDepthwiseConvolutionWorkloadValidate, |
| 378 | reasonIfUnsupported, |
| 379 | input, |
| 380 | output, |
| 381 | descriptor, |
| 382 | weights, |
| 383 | biases); |
| 384 | } |
| 385 | |
| 386 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 387 | bool ClLayerSupport::IsDivisionSupported(const TensorInfo& input0, |
| 388 | const TensorInfo& input1, |
| 389 | const TensorInfo& output, |
| 390 | Optional<std::string&> reasonIfUnsupported) const |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 391 | { |
| 392 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDivisionWorkloadValidate, |
| 393 | reasonIfUnsupported, |
| 394 | input0, |
| 395 | input1, |
| 396 | output); |
| 397 | } |
| 398 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 399 | bool ClLayerSupport::IsElementwiseUnarySupported(const TensorInfo& input, |
| 400 | const TensorInfo& output, |
| 401 | const ElementwiseUnaryDescriptor& descriptor, |
| 402 | Optional<std::string&> reasonIfUnsupported) const |
| 403 | { |
Sadik Armagan | 9fabf43 | 2020-05-27 13:40:58 +0100 | [diff] [blame] | 404 | switch(descriptor.m_Operation) |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 405 | { |
Sadik Armagan | 9fabf43 | 2020-05-27 13:40:58 +0100 | [diff] [blame] | 406 | case UnaryOperation::Abs: |
| 407 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClAbsWorkloadValidate, |
| 408 | reasonIfUnsupported, |
| 409 | input, |
| 410 | output); |
| 411 | case UnaryOperation::Exp: |
| 412 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClExpWorkloadValidate, |
| 413 | reasonIfUnsupported, |
| 414 | input, |
| 415 | output); |
| 416 | case UnaryOperation::Neg: |
| 417 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClNegWorkloadValidate, |
| 418 | reasonIfUnsupported, |
| 419 | input, |
| 420 | output); |
| 421 | case UnaryOperation::Rsqrt: |
| 422 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClRsqrtWorkloadValidate, |
| 423 | reasonIfUnsupported, |
| 424 | input, |
| 425 | output); |
| 426 | default: |
| 427 | return false; |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 428 | } |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 429 | } |
| 430 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 431 | bool ClLayerSupport::IsFloorSupported(const TensorInfo& input, |
| 432 | const TensorInfo& output, |
| 433 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 434 | { |
Sadik Armagan | 9be4916 | 2019-10-30 16:15:26 +0000 | [diff] [blame] | 435 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClFloorWorkloadValidate, |
| 436 | reasonIfUnsupported, |
| 437 | input, |
| 438 | output); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 439 | } |
| 440 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 441 | bool ClLayerSupport::IsFullyConnectedSupported(const TensorInfo& input, |
| 442 | const TensorInfo& output, |
| 443 | const TensorInfo& weights, |
| 444 | const TensorInfo& biases, |
| 445 | const FullyConnectedDescriptor& descriptor, |
| 446 | Optional<std::string&> reasonIfUnsupported) const |
| 447 | { |
| 448 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClFullyConnectedWorkloadValidate, |
| 449 | reasonIfUnsupported, |
| 450 | input, |
| 451 | output, |
| 452 | weights, |
| 453 | biases, |
| 454 | descriptor); |
| 455 | } |
| 456 | |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame^] | 457 | bool ClLayerSupport::IsGatherSupported(const TensorInfo& input0, |
| 458 | const TensorInfo& input1, |
| 459 | const TensorInfo& output, |
| 460 | Optional<std::string&> reasonIfUnsupported) const |
| 461 | { |
| 462 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClGatherWorkloadValidate, |
| 463 | reasonIfUnsupported, |
| 464 | input0, |
| 465 | input1, |
| 466 | output); |
| 467 | } |
| 468 | |
Nattapat Chaimanowong | c6a41ff | 2019-01-29 09:56:02 +0000 | [diff] [blame] | 469 | bool ClLayerSupport::IsGreaterSupported(const TensorInfo& input0, |
| 470 | const TensorInfo& input1, |
| 471 | const TensorInfo& output, |
| 472 | Optional<std::string&> reasonIfUnsupported) const |
| 473 | { |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 474 | ComparisonDescriptor descriptor(ComparisonOperation::Greater); |
| 475 | return IsComparisonSupported(input0, input1, output, descriptor, reasonIfUnsupported); |
Nattapat Chaimanowong | c6a41ff | 2019-01-29 09:56:02 +0000 | [diff] [blame] | 476 | } |
| 477 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 478 | bool ClLayerSupport::IsInputSupported(const TensorInfo& input, |
| 479 | Optional<std::string&> reasonIfUnsupported) const |
| 480 | { |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 481 | return IsClBackendSupported(reasonIfUnsupported, input); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 482 | } |
| 483 | |
Aron Virginas-Tar | 8168f40 | 2019-10-04 13:10:16 +0100 | [diff] [blame] | 484 | bool ClLayerSupport::IsInstanceNormalizationSupported(const TensorInfo& input, |
| 485 | const TensorInfo& output, |
| 486 | const InstanceNormalizationDescriptor& descriptor, |
| 487 | Optional<std::string&> reasonIfUnsupported) const |
| 488 | { |
| 489 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClInstanceNormalizationWorkloadValidate, |
| 490 | reasonIfUnsupported, |
| 491 | input, |
| 492 | output, |
| 493 | descriptor); |
| 494 | } |
| 495 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 496 | bool ClLayerSupport::IsL2NormalizationSupported(const TensorInfo& input, |
| 497 | const TensorInfo& output, |
| 498 | const L2NormalizationDescriptor& descriptor, |
| 499 | Optional<std::string&> reasonIfUnsupported) const |
| 500 | { |
| 501 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClL2NormalizationWorkloadValidate, |
| 502 | reasonIfUnsupported, |
| 503 | input, |
| 504 | output, |
| 505 | descriptor); |
| 506 | } |
| 507 | |
| 508 | bool ClLayerSupport::IsLstmSupported(const TensorInfo& input, |
| 509 | const TensorInfo& outputStateIn, |
| 510 | const TensorInfo& cellStateIn, |
| 511 | const TensorInfo& scratchBuffer, |
| 512 | const TensorInfo& outputStateOut, |
| 513 | const TensorInfo& cellStateOut, |
| 514 | const TensorInfo& output, |
| 515 | const LstmDescriptor& descriptor, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 516 | const LstmInputParamsInfo& paramsInfo, |
| 517 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 518 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 519 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClLstmFloatWorkloadValidate, |
| 520 | reasonIfUnsupported, |
| 521 | input, |
| 522 | outputStateIn, |
| 523 | cellStateIn, |
| 524 | scratchBuffer, |
| 525 | outputStateOut, |
| 526 | cellStateOut, |
| 527 | output, |
| 528 | descriptor, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 529 | paramsInfo); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 530 | } |
| 531 | |
keidav01 | a959ee5 | 2018-12-19 10:04:58 +0000 | [diff] [blame] | 532 | bool ClLayerSupport::IsMaximumSupported(const TensorInfo& input0, |
| 533 | const TensorInfo& input1, |
| 534 | const TensorInfo& output, |
| 535 | Optional<std::string&> reasonIfUnsupported) const |
| 536 | { |
| 537 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMaximumWorkloadValidate, |
| 538 | reasonIfUnsupported, |
| 539 | input0, |
| 540 | input1, |
| 541 | output); |
| 542 | } |
| 543 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 544 | bool ClLayerSupport::IsMeanSupported(const TensorInfo& input, |
| 545 | const TensorInfo& output, |
| 546 | const MeanDescriptor& descriptor, |
| 547 | Optional<std::string&> reasonIfUnsupported) const |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 548 | { |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 549 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMeanValidate, |
| 550 | reasonIfUnsupported, |
| 551 | input, |
| 552 | output, |
| 553 | descriptor); |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 554 | } |
| 555 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 556 | bool ClLayerSupport::IsMergerSupported(const std::vector<const TensorInfo*> inputs, |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 557 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 558 | const MergerDescriptor& descriptor, |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 559 | Optional<std::string&> reasonIfUnsupported) const |
| 560 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 561 | return IsConcatSupported(inputs, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 562 | } |
| 563 | |
saoste01 | 9292aa3 | 2019-01-08 13:55:59 +0000 | [diff] [blame] | 564 | bool ClLayerSupport::IsMinimumSupported(const TensorInfo& input0, |
| 565 | const TensorInfo& input1, |
| 566 | const TensorInfo& output, |
| 567 | Optional<std::string&> reasonIfUnsupported) const |
| 568 | { |
| 569 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMinimumWorkloadValidate, |
| 570 | reasonIfUnsupported, |
| 571 | input0, |
| 572 | input1, |
| 573 | output); |
| 574 | } |
| 575 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 576 | bool ClLayerSupport::IsMultiplicationSupported(const TensorInfo& input0, |
| 577 | const TensorInfo& input1, |
| 578 | const TensorInfo& output, |
| 579 | Optional<std::string&> reasonIfUnsupported) const |
| 580 | { |
| 581 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMultiplicationWorkloadValidate, |
| 582 | reasonIfUnsupported, |
| 583 | input0, |
| 584 | input1, |
| 585 | output); |
| 586 | } |
| 587 | |
| 588 | bool ClLayerSupport::IsNormalizationSupported(const TensorInfo& input, |
| 589 | const TensorInfo& output, |
| 590 | const NormalizationDescriptor& descriptor, |
| 591 | Optional<std::string&> reasonIfUnsupported) const |
| 592 | { |
| 593 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClNormalizationWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 594 | } |
| 595 | |
| 596 | bool ClLayerSupport::IsOutputSupported(const TensorInfo& output, |
| 597 | Optional<std::string&> reasonIfUnsupported) const |
| 598 | { |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 599 | return IsClBackendSupported(reasonIfUnsupported, output); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 600 | } |
| 601 | |
| 602 | bool ClLayerSupport::IsPadSupported(const TensorInfo& input, |
| 603 | const TensorInfo& output, |
| 604 | const PadDescriptor& descriptor, |
| 605 | Optional<std::string&> reasonIfUnsupported) const |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 606 | { |
| 607 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPadValidate, |
| 608 | reasonIfUnsupported, |
| 609 | input, |
| 610 | output, |
| 611 | descriptor); |
| 612 | } |
| 613 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 614 | bool ClLayerSupport::IsPermuteSupported(const TensorInfo& input, |
| 615 | const TensorInfo& output, |
| 616 | const PermuteDescriptor& descriptor, |
| 617 | Optional<std::string&> reasonIfUnsupported) const |
| 618 | { |
Matthew Bentham | 9820d30 | 2019-11-27 17:24:47 +0000 | [diff] [blame] | 619 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPermuteWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 620 | } |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 621 | |
| 622 | bool ClLayerSupport::IsPooling2dSupported(const TensorInfo& input, |
| 623 | const TensorInfo& output, |
| 624 | const Pooling2dDescriptor& descriptor, |
| 625 | Optional<std::string&> reasonIfUnsupported) const |
| 626 | { |
| 627 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPooling2dWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 628 | } |
| 629 | |
Nikhil Raj | 91e4c6d | 2019-07-05 12:22:58 +0100 | [diff] [blame] | 630 | bool ClLayerSupport::IsPreluSupported(const armnn::TensorInfo &input, |
| 631 | const armnn::TensorInfo &alpha, |
| 632 | const armnn::TensorInfo &output, |
| 633 | armnn::Optional<std::string &> reasonIfUnsupported) const |
| 634 | { |
| 635 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPreluWorkloadValidate, reasonIfUnsupported, input, alpha, output); |
| 636 | } |
| 637 | |
Ryan OShea | 2323af4 | 2020-05-13 16:36:19 +0100 | [diff] [blame] | 638 | bool ClLayerSupport::IsQLstmSupported(const TensorInfo& input, |
| 639 | const TensorInfo& previousOutputIn, |
| 640 | const TensorInfo& previousCellStateIn, |
| 641 | const TensorInfo& outputStateOut, |
| 642 | const TensorInfo& cellStateOut, |
| 643 | const TensorInfo& output, |
| 644 | const QLstmDescriptor& descriptor, |
| 645 | const LstmInputParamsInfo& paramsInfo, |
| 646 | Optional<std::string&> reasonIfUnsupported) const |
| 647 | { |
| 648 | if (input.GetDataType() == armnn::DataType::QAsymmS8 && |
| 649 | previousOutputIn.GetDataType() == armnn::DataType::QAsymmS8 && |
| 650 | previousCellStateIn.GetDataType() == armnn::DataType::QSymmS16 && |
| 651 | outputStateOut.GetDataType() == armnn::DataType::QAsymmS8 && |
| 652 | cellStateOut.GetDataType() == armnn::DataType::QSymmS16 && |
| 653 | output.GetDataType() == armnn::DataType::QAsymmS8) |
| 654 | { |
| 655 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClQLstmWorkloadValidate, |
| 656 | reasonIfUnsupported, |
| 657 | input, |
| 658 | previousCellStateIn, |
| 659 | previousOutputIn, |
| 660 | cellStateOut, |
| 661 | outputStateOut, |
| 662 | output, |
| 663 | descriptor, |
| 664 | paramsInfo); |
| 665 | } |
| 666 | else |
| 667 | { |
| 668 | return false; |
| 669 | } |
| 670 | } |
| 671 | |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 672 | bool ClLayerSupport::IsQuantizedLstmSupported(const TensorInfo& input, |
| 673 | const TensorInfo& previousCellStateIn, |
| 674 | const TensorInfo& previousOutputIn, |
| 675 | const TensorInfo& cellStateOut, |
| 676 | const TensorInfo& output, |
| 677 | const QuantizedLstmInputParamsInfo& paramsInfo, |
| 678 | Optional<std::string&> reasonIfUnsupported) const |
| 679 | { |
| 680 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClQuantizedLstmWorkloadValidate, |
| 681 | reasonIfUnsupported, |
| 682 | input, |
| 683 | previousCellStateIn, |
| 684 | previousOutputIn, |
| 685 | cellStateOut, |
| 686 | output, |
| 687 | paramsInfo); |
| 688 | } |
| 689 | |
Sadik Armagan | 20ec249 | 2019-05-31 09:09:44 +0100 | [diff] [blame] | 690 | bool ClLayerSupport::IsQuantizeSupported(const TensorInfo& input, |
| 691 | const TensorInfo& output, |
| 692 | Optional<std::string&> reasonIfUnsupported) const |
| 693 | { |
| 694 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClQuantizeWorkloadValidate, |
| 695 | reasonIfUnsupported, |
| 696 | input, |
| 697 | output); |
| 698 | } |
| 699 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 700 | bool ClLayerSupport::IsReshapeSupported(const TensorInfo& input, |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 701 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 702 | const ReshapeDescriptor& descriptor, |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 703 | Optional<std::string&> reasonIfUnsupported) const |
| 704 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 705 | IgnoreUnused(descriptor); |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 706 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClReshapeWorkloadValidate, reasonIfUnsupported, input, output); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 707 | } |
| 708 | |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 709 | bool ClLayerSupport::IsResizeSupported(const TensorInfo& input, |
| 710 | const TensorInfo& output, |
| 711 | const ResizeDescriptor& descriptor, |
| 712 | Optional<std::string&> reasonIfUnsupported) const |
| 713 | { |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 714 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClResizeWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 715 | } |
| 716 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 717 | bool ClLayerSupport::IsResizeBilinearSupported(const TensorInfo& input, |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame] | 718 | const TensorInfo& output, |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 719 | Optional<std::string&> reasonIfUnsupported) const |
| 720 | { |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 721 | ResizeDescriptor descriptor; |
| 722 | descriptor.m_Method = ResizeMethod::Bilinear; |
| 723 | descriptor.m_DataLayout = DataLayout::NCHW; |
| 724 | |
| 725 | const TensorShape& outputShape = output.GetShape(); |
| 726 | descriptor.m_TargetHeight = outputShape[2]; |
| 727 | descriptor.m_TargetWidth = outputShape[3]; |
| 728 | |
| 729 | return IsResizeSupported(input, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 730 | } |
| 731 | |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 732 | bool ClLayerSupport::IsRsqrtSupported(const TensorInfo& input, |
| 733 | const TensorInfo& output, |
| 734 | Optional<std::string&> reasonIfUnsupported) const |
| 735 | { |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 736 | ElementwiseUnaryDescriptor descriptor(UnaryOperation::Rsqrt); |
| 737 | return IsElementwiseUnarySupported(input, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 738 | } |
| 739 | |
Aron Virginas-Tar | 94c4fef | 2019-11-25 15:37:08 +0000 | [diff] [blame] | 740 | bool ClLayerSupport::IsSliceSupported(const TensorInfo& input, |
| 741 | const TensorInfo& output, |
| 742 | const SliceDescriptor& descriptor, |
| 743 | Optional<std::string&> reasonIfUnsupported) const |
| 744 | { |
| 745 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSliceWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 746 | } |
| 747 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 748 | bool ClLayerSupport::IsSoftmaxSupported(const TensorInfo& input, |
| 749 | const TensorInfo& output, |
| 750 | const SoftmaxDescriptor& descriptor, |
| 751 | Optional<std::string&> reasonIfUnsupported) const |
| 752 | { |
Francis Murtagh | 3b93835 | 2019-07-26 15:44:17 +0100 | [diff] [blame] | 753 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSoftmaxWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 754 | } |
| 755 | |
Sadik Armagan | f446432 | 2018-12-20 16:19:12 +0000 | [diff] [blame] | 756 | bool ClLayerSupport::IsSpaceToBatchNdSupported(const TensorInfo& input, |
| 757 | const TensorInfo& output, |
| 758 | const SpaceToBatchNdDescriptor& descriptor, |
| 759 | Optional<std::string&> reasonIfUnsupported) const |
| 760 | { |
| 761 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSpaceToBatchNdWorkloadValidate, |
| 762 | reasonIfUnsupported, |
| 763 | input, |
| 764 | output, |
| 765 | descriptor); |
| 766 | } |
| 767 | |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 768 | bool ClLayerSupport::IsSpaceToDepthSupported(const TensorInfo& input, |
| 769 | const TensorInfo& output, |
| 770 | const SpaceToDepthDescriptor& descriptor, |
| 771 | Optional<std::string&> reasonIfUnsupported) const |
| 772 | { |
| 773 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSpaceToDepthWorkloadValidate, |
| 774 | reasonIfUnsupported, |
| 775 | input, |
| 776 | output, |
| 777 | descriptor); |
| 778 | } |
| 779 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 780 | bool ClLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 781 | const ViewsDescriptor& descriptor, |
| 782 | Optional<std::string&> reasonIfUnsupported) const |
| 783 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 784 | IgnoreUnused(descriptor); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 785 | return IsSupportedForDataTypeCl(reasonIfUnsupported, |
| 786 | input.GetDataType(), |
| 787 | &TrueFunc<>, |
| 788 | &TrueFunc<>); |
| 789 | } |
| 790 | |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 791 | bool ClLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 792 | const std::vector<std::reference_wrapper<TensorInfo>>& outputs, |
| 793 | const ViewsDescriptor& descriptor, |
| 794 | Optional<std::string&> reasonIfUnsupported) const |
| 795 | { |
Narumol Prangnawarat | 7413583 | 2019-05-23 15:07:33 +0100 | [diff] [blame] | 796 | #if defined(ARMCOMPUTECL_ENABLED) |
| 797 | // Split along the last dimension, cannot use sub-tensors |
| 798 | // as width and height of the sub-tensors do not match |
| 799 | // the width and height of the parent tensor |
| 800 | // in case of input with more than 2D. |
| 801 | std::set<unsigned int> splitAxis = ComputeSplitAxis(descriptor, input.GetShape()); |
| 802 | if (descriptor.GetNumDimensions() > 2 && splitAxis.size() == 1 && |
| 803 | *splitAxis.begin() == descriptor.GetNumDimensions() - 1 ) |
| 804 | { |
| 805 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSplitterWorkloadValidate, |
| 806 | reasonIfUnsupported, |
| 807 | input, |
| 808 | outputs, |
| 809 | *splitAxis.begin()); |
| 810 | } |
| 811 | #endif |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 812 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | 7413583 | 2019-05-23 15:07:33 +0100 | [diff] [blame] | 813 | for (auto output : outputs) |
| 814 | { |
| 815 | if (!input.IsTypeSpaceMatch(output)) // Cannot use sub-tensors if the types are not same space |
| 816 | { |
| 817 | SetValueChecked(reasonIfUnsupported, "Cl Splitter: Types and quantization parameters must match."); |
| 818 | return false; |
| 819 | } |
| 820 | } |
| 821 | return true; |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 822 | } |
| 823 | |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 824 | bool ClLayerSupport::IsStackSupported(const std::vector<const TensorInfo*>& inputs, |
| 825 | const TensorInfo& output, |
| 826 | const StackDescriptor& descriptor, |
| 827 | Optional<std::string&> reasonIfUnsupported) const |
| 828 | { |
| 829 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClStackWorkloadValidate, |
| 830 | reasonIfUnsupported, |
| 831 | inputs, |
| 832 | output, |
| 833 | descriptor); |
| 834 | } |
| 835 | |
keidav01 | d74dc91 | 2018-12-10 18:16:07 +0000 | [diff] [blame] | 836 | bool ClLayerSupport::IsStridedSliceSupported(const TensorInfo& input, |
| 837 | const TensorInfo& output, |
| 838 | const StridedSliceDescriptor& descriptor, |
| 839 | Optional<std::string&> reasonIfUnsupported) const |
| 840 | { |
| 841 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClStridedSliceWorkloadValidate, |
| 842 | reasonIfUnsupported, |
| 843 | input, |
| 844 | output, |
| 845 | descriptor); |
| 846 | } |
| 847 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 848 | bool ClLayerSupport::IsSubtractionSupported(const TensorInfo& input0, |
| 849 | const TensorInfo& input1, |
| 850 | const TensorInfo& output, |
| 851 | Optional<std::string&> reasonIfUnsupported) const |
| 852 | { |
| 853 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSubtractionValidate, |
| 854 | reasonIfUnsupported, |
| 855 | input0, |
| 856 | input1, |
| 857 | output); |
| 858 | } |
| 859 | |
Aron Virginas-Tar | 7a3e2fe | 2019-06-27 18:54:47 +0100 | [diff] [blame] | 860 | bool ClLayerSupport::IsTransposeConvolution2dSupported(const TensorInfo& input, |
| 861 | const TensorInfo& output, |
| 862 | const TransposeConvolution2dDescriptor& descriptor, |
| 863 | const TensorInfo& weights, |
| 864 | const Optional<TensorInfo>& biases, |
| 865 | Optional<std::string&> reasonIfUnsupported) const |
| 866 | { |
| 867 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClTransposeConvolution2dWorkloadValidate, |
| 868 | reasonIfUnsupported, |
| 869 | input, |
| 870 | output, |
| 871 | descriptor, |
| 872 | weights, |
| 873 | biases); |
| 874 | } |
| 875 | |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 876 | bool ClLayerSupport::IsTransposeSupported(const TensorInfo& input, |
| 877 | const TensorInfo& output, |
| 878 | const TransposeDescriptor& descriptor, |
| 879 | Optional<std::string&> reasonIfUnsupported) const |
| 880 | { |
| 881 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClTransposeWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 882 | } |
| 883 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 884 | } // namespace armnn |