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