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 | |
David Beck | 3cc9a62 | 2018-10-12 10:38:31 +0100 | [diff] [blame] | 9 | #include <armnn/Descriptors.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 10 | #include <InternalTypes.hpp> |
| 11 | #include <LayerSupportCommon.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 12 | |
David Beck | 111b5d9 | 2018-11-12 14:59:37 +0000 | [diff] [blame] | 13 | #include <backendsCommon/BackendRegistry.hpp> |
David Beck | 3e9e115 | 2018-10-17 14:17:50 +0100 | [diff] [blame] | 14 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 15 | #include <boost/core/ignore_unused.hpp> |
| 16 | |
| 17 | #ifdef ARMCOMPUTECL_ENABLED |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 18 | #include "workloads/ClAdditionWorkload.hpp" |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 19 | #include "workloads/ClActivationWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 20 | #include "workloads/ClBatchNormalizationFloatWorkload.hpp" |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 21 | #include "workloads/ClBatchToSpaceNdWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 22 | #include "workloads/ClConvertFp16ToFp32Workload.hpp" |
| 23 | #include "workloads/ClConvertFp32ToFp16Workload.hpp" |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 24 | #include "workloads/ClConvolution2dWorkload.hpp" |
Matthew Bentham | d877739 | 2018-10-08 09:38:55 +0100 | [diff] [blame] | 25 | #include "workloads/ClDepthwiseConvolutionWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 26 | #include "workloads/ClDivisionFloatWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 27 | #include "workloads/ClFullyConnectedWorkload.hpp" |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 28 | #include "workloads/ClL2NormalizationFloatWorkload.hpp" |
| 29 | #include "workloads/ClLstmFloatWorkload.hpp" |
keidav01 | a959ee5 | 2018-12-19 10:04:58 +0000 | [diff] [blame] | 30 | #include "workloads/ClMaximumWorkload.hpp" |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 31 | #include "workloads/ClMeanWorkload.hpp" |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 32 | #include "workloads/ClMergerWorkload.hpp" |
saoste01 | 9292aa3 | 2019-01-08 13:55:59 +0000 | [diff] [blame] | 33 | #include "workloads/ClMinimumWorkload.hpp" |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 34 | #include "workloads/ClMultiplicationWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 35 | #include "workloads/ClNormalizationFloatWorkload.hpp" |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 36 | #include "workloads/ClPadWorkload.hpp" |
| 37 | #include "workloads/ClPermuteWorkload.hpp" |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 38 | #include "workloads/ClPooling2dWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 39 | #include "workloads/ClSoftmaxBaseWorkload.hpp" |
Sadik Armagan | f446432 | 2018-12-20 16:19:12 +0000 | [diff] [blame] | 40 | #include "workloads/ClSpaceToBatchNdWorkload.hpp" |
keidav01 | d74dc91 | 2018-12-10 18:16:07 +0000 | [diff] [blame] | 41 | #include "workloads/ClStridedSliceWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 42 | #include "workloads/ClSubtractionWorkload.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 43 | #endif |
| 44 | |
| 45 | using namespace boost; |
| 46 | |
| 47 | namespace armnn |
| 48 | { |
arovir01 | 7c22c70 | 2018-10-09 11:16:46 +0100 | [diff] [blame] | 49 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 50 | namespace |
| 51 | { |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 52 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 53 | template<unsigned int FilterSize> |
| 54 | bool IsMatchingSize2d(const TensorInfo& weightInfo) |
| 55 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 56 | // Width & Height must match. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 57 | return (weightInfo.GetShape()[3] == FilterSize) && (weightInfo.GetShape()[2] == FilterSize); |
| 58 | } |
| 59 | |
| 60 | template<uint32_t ValidStride> |
| 61 | bool IsMatchingStride(uint32_t actualStride) |
| 62 | { |
| 63 | return ValidStride == actualStride; |
| 64 | } |
| 65 | |
| 66 | template<uint32_t FirstStride, uint32_t SecondStride, uint32_t... ValidStrides> |
| 67 | bool IsMatchingStride(uint32_t actualStride) |
| 68 | { |
| 69 | return IsMatchingStride<FirstStride>(actualStride) || IsMatchingStride<SecondStride, ValidStrides...>(actualStride); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 70 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 71 | |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 72 | bool IsClBackendSupported(Optional<std::string&> reasonIfUnsupported) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 73 | { |
| 74 | #if ARMCOMPUTECL_ENABLED |
| 75 | return true; |
| 76 | #else |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 77 | if (reasonIfUnsupported) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 78 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 79 | reasonIfUnsupported.value() = "The armnn library has been built without CL support"; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 80 | } |
| 81 | return false; |
| 82 | #endif |
| 83 | } |
| 84 | |
| 85 | #if ARMCOMPUTECL_ENABLED |
| 86 | #define FORWARD_CL_LAYER_SUPPORT_FUNC(expr) (expr) |
| 87 | #else |
| 88 | #define FORWARD_CL_LAYER_SUPPORT_FUNC(expr) IsClBackendSupported(reasonIfUnsupported) |
| 89 | #endif |
| 90 | |
| 91 | #if ARMCOMPUTECL_ENABLED |
| 92 | template<class FuncType, class... Args> |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 93 | inline bool IsWorkloadSupported(FuncType&& func, Optional<std::string&> reasonIfUnsupported, Args&&... args) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 94 | { |
| 95 | arm_compute::Status aclStatus = func(std::forward<Args>(args)...); |
| 96 | const bool supported = (aclStatus.error_code() == arm_compute::ErrorCode::OK); |
| 97 | if (!supported && reasonIfUnsupported) |
| 98 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 99 | reasonIfUnsupported.value() = aclStatus.error_description(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 100 | } |
| 101 | return supported; |
| 102 | } |
| 103 | |
| 104 | #define FORWARD_WORKLOAD_VALIDATE_FUNC(func, reasonIfUnsupported, ...) \ |
| 105 | return IsWorkloadSupported(func, reasonIfUnsupported, __VA_ARGS__); |
| 106 | #else |
| 107 | #define FORWARD_WORKLOAD_VALIDATE_FUNC(func, reasonIfUnsupported, ...) \ |
| 108 | return IsClBackendSupported(reasonIfUnsupported); |
| 109 | #endif |
| 110 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 111 | template<typename FloatFunc, typename Uint8Func, typename ... Params> |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 112 | bool IsSupportedForDataTypeCl(Optional<std::string&> reasonIfUnsupported, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 113 | DataType dataType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 114 | FloatFunc floatFuncPtr, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 115 | Uint8Func uint8FuncPtr, |
| 116 | Params&&... params) |
| 117 | { |
| 118 | return IsClBackendSupported(reasonIfUnsupported) && |
| 119 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 120 | dataType, |
| 121 | floatFuncPtr, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 122 | floatFuncPtr, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 123 | uint8FuncPtr, |
| 124 | std::forward<Params>(params)...); |
| 125 | } |
| 126 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 127 | } // anonymous namespace |
| 128 | |
| 129 | bool ClLayerSupport::IsActivationSupported(const TensorInfo& input, |
| 130 | const TensorInfo& output, |
| 131 | const ActivationDescriptor& descriptor, |
| 132 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 133 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 134 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClActivationWorkloadValidate, |
| 135 | reasonIfUnsupported, |
| 136 | input, |
| 137 | output, |
| 138 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 139 | } |
| 140 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 141 | bool ClLayerSupport::IsAdditionSupported(const TensorInfo& input0, |
| 142 | const TensorInfo& input1, |
| 143 | const TensorInfo& output, |
| 144 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 145 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 146 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClAdditionValidate, |
| 147 | reasonIfUnsupported, |
| 148 | input0, |
| 149 | input1, |
| 150 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 151 | } |
| 152 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 153 | bool ClLayerSupport::IsBatchNormalizationSupported(const TensorInfo& input, |
| 154 | const TensorInfo& output, |
| 155 | const TensorInfo& mean, |
| 156 | const TensorInfo& var, |
| 157 | const TensorInfo& beta, |
| 158 | const TensorInfo& gamma, |
| 159 | const BatchNormalizationDescriptor& descriptor, |
| 160 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 161 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 162 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClBatchNormalizationValidate, |
| 163 | reasonIfUnsupported, |
| 164 | input, |
| 165 | output, |
| 166 | mean, |
| 167 | var, |
| 168 | beta, |
| 169 | gamma, |
| 170 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 171 | } |
| 172 | |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 173 | bool ClLayerSupport::IsBatchToSpaceNdSupported(const TensorInfo& input, |
| 174 | const TensorInfo& output, |
| 175 | const BatchToSpaceNdDescriptor& descriptor, |
| 176 | Optional<std::string&> reasonIfUnsupported) const |
| 177 | { |
| 178 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClBatchToSpaceNdWorkloadValidate, |
| 179 | reasonIfUnsupported, |
| 180 | input, |
| 181 | output, |
| 182 | descriptor); |
| 183 | } |
| 184 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 185 | bool ClLayerSupport::IsConstantSupported(const TensorInfo& output, |
| 186 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 187 | { |
| 188 | return IsSupportedForDataTypeCl(reasonIfUnsupported, |
| 189 | output.GetDataType(), |
| 190 | &TrueFunc<>, |
| 191 | &FalseFuncU8<>); |
| 192 | } |
| 193 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 194 | bool ClLayerSupport::IsConvertFp16ToFp32Supported(const TensorInfo& input, |
| 195 | const TensorInfo& output, |
| 196 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 197 | { |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 198 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConvertFp16ToFp32WorkloadValidate, |
| 199 | reasonIfUnsupported, |
| 200 | input, |
| 201 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 202 | } |
| 203 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 204 | bool ClLayerSupport::IsConvertFp32ToFp16Supported(const TensorInfo& input, |
| 205 | const TensorInfo& output, |
| 206 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 207 | { |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 208 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConvertFp32ToFp16WorkloadValidate, |
| 209 | reasonIfUnsupported, |
| 210 | input, |
| 211 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 212 | } |
| 213 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 214 | bool ClLayerSupport::IsConvolution2dSupported(const TensorInfo& input, |
| 215 | const TensorInfo& output, |
| 216 | const Convolution2dDescriptor& descriptor, |
| 217 | const TensorInfo& weights, |
| 218 | const Optional<TensorInfo>& biases, |
| 219 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 220 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 221 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConvolution2dWorkloadValidate, |
| 222 | reasonIfUnsupported, |
| 223 | input, |
| 224 | output, |
| 225 | descriptor, |
| 226 | weights, |
| 227 | biases); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 228 | } |
| 229 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 230 | bool ClLayerSupport::IsDepthwiseConvolutionSupported(const TensorInfo& input, |
| 231 | const TensorInfo& output, |
| 232 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 233 | const TensorInfo& weights, |
| 234 | const Optional<TensorInfo>& biases, |
| 235 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 236 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 237 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDepthwiseConvolutionWorkloadValidate, |
| 238 | reasonIfUnsupported, |
| 239 | input, |
| 240 | output, |
| 241 | descriptor, |
| 242 | weights, |
| 243 | biases); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 244 | } |
| 245 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 246 | bool ClLayerSupport::IsDivisionSupported(const TensorInfo& input0, |
| 247 | const TensorInfo& input1, |
| 248 | const TensorInfo& output, |
| 249 | Optional<std::string&> reasonIfUnsupported) const |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 250 | { |
| 251 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDivisionWorkloadValidate, |
| 252 | reasonIfUnsupported, |
| 253 | input0, |
| 254 | input1, |
| 255 | output); |
| 256 | } |
| 257 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 258 | bool ClLayerSupport::IsFloorSupported(const TensorInfo& input, |
| 259 | const TensorInfo& output, |
| 260 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 261 | { |
| 262 | ignore_unused(output); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 263 | return IsClBackendSupported(reasonIfUnsupported) && |
| 264 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 265 | input.GetDataType(), |
| 266 | &FalseFuncF16<>, |
| 267 | &TrueFunc<>, |
| 268 | &FalseFuncU8<>); |
| 269 | } |
| 270 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 271 | bool ClLayerSupport::IsFullyConnectedSupported(const TensorInfo& input, |
| 272 | const TensorInfo& output, |
| 273 | const TensorInfo& weights, |
| 274 | const TensorInfo& biases, |
| 275 | const FullyConnectedDescriptor& descriptor, |
| 276 | Optional<std::string&> reasonIfUnsupported) const |
| 277 | { |
| 278 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClFullyConnectedWorkloadValidate, |
| 279 | reasonIfUnsupported, |
| 280 | input, |
| 281 | output, |
| 282 | weights, |
| 283 | biases, |
| 284 | descriptor); |
| 285 | } |
| 286 | |
| 287 | bool ClLayerSupport::IsInputSupported(const TensorInfo& input, |
| 288 | Optional<std::string&> reasonIfUnsupported) const |
| 289 | { |
| 290 | return IsSupportedForDataTypeCl(reasonIfUnsupported, |
| 291 | input.GetDataType(), |
| 292 | &TrueFunc<>, |
| 293 | &TrueFunc<>); |
| 294 | } |
| 295 | |
| 296 | bool ClLayerSupport::IsL2NormalizationSupported(const TensorInfo& input, |
| 297 | const TensorInfo& output, |
| 298 | const L2NormalizationDescriptor& descriptor, |
| 299 | Optional<std::string&> reasonIfUnsupported) const |
| 300 | { |
| 301 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClL2NormalizationWorkloadValidate, |
| 302 | reasonIfUnsupported, |
| 303 | input, |
| 304 | output, |
| 305 | descriptor); |
| 306 | } |
| 307 | |
| 308 | bool ClLayerSupport::IsLstmSupported(const TensorInfo& input, |
| 309 | const TensorInfo& outputStateIn, |
| 310 | const TensorInfo& cellStateIn, |
| 311 | const TensorInfo& scratchBuffer, |
| 312 | const TensorInfo& outputStateOut, |
| 313 | const TensorInfo& cellStateOut, |
| 314 | const TensorInfo& output, |
| 315 | const LstmDescriptor& descriptor, |
| 316 | const TensorInfo& inputToForgetWeights, |
| 317 | const TensorInfo& inputToCellWeights, |
| 318 | const TensorInfo& inputToOutputWeights, |
| 319 | const TensorInfo& recurrentToForgetWeights, |
| 320 | const TensorInfo& recurrentToCellWeights, |
| 321 | const TensorInfo& recurrentToOutputWeights, |
| 322 | const TensorInfo& forgetGateBias, |
| 323 | const TensorInfo& cellBias, |
| 324 | const TensorInfo& outputGateBias, |
| 325 | const TensorInfo* inputToInputWeights, |
| 326 | const TensorInfo* recurrentToInputWeights, |
| 327 | const TensorInfo* cellToInputWeights, |
| 328 | const TensorInfo* inputGateBias, |
| 329 | const TensorInfo* projectionWeights, |
| 330 | const TensorInfo* projectionBias, |
| 331 | const TensorInfo* cellToForgetWeights, |
| 332 | const TensorInfo* cellToOutputWeights, |
| 333 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 334 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 335 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClLstmFloatWorkloadValidate, |
| 336 | reasonIfUnsupported, |
| 337 | input, |
| 338 | outputStateIn, |
| 339 | cellStateIn, |
| 340 | scratchBuffer, |
| 341 | outputStateOut, |
| 342 | cellStateOut, |
| 343 | output, |
| 344 | descriptor, |
| 345 | inputToForgetWeights, |
| 346 | inputToCellWeights, |
| 347 | inputToOutputWeights, |
| 348 | recurrentToForgetWeights, |
| 349 | recurrentToCellWeights, |
| 350 | recurrentToOutputWeights, |
| 351 | forgetGateBias, |
| 352 | cellBias, |
| 353 | outputGateBias, |
| 354 | inputToInputWeights, |
| 355 | recurrentToInputWeights, |
| 356 | cellToInputWeights, |
| 357 | inputGateBias, |
| 358 | projectionWeights, |
| 359 | projectionBias, |
| 360 | cellToForgetWeights, |
| 361 | cellToOutputWeights); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 362 | } |
| 363 | |
keidav01 | a959ee5 | 2018-12-19 10:04:58 +0000 | [diff] [blame] | 364 | bool ClLayerSupport::IsMaximumSupported(const TensorInfo& input0, |
| 365 | const TensorInfo& input1, |
| 366 | const TensorInfo& output, |
| 367 | Optional<std::string&> reasonIfUnsupported) const |
| 368 | { |
| 369 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMaximumWorkloadValidate, |
| 370 | reasonIfUnsupported, |
| 371 | input0, |
| 372 | input1, |
| 373 | output); |
| 374 | } |
| 375 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 376 | bool ClLayerSupport::IsMeanSupported(const TensorInfo& input, |
| 377 | const TensorInfo& output, |
| 378 | const MeanDescriptor& descriptor, |
| 379 | Optional<std::string&> reasonIfUnsupported) const |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 380 | { |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 381 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMeanValidate, |
| 382 | reasonIfUnsupported, |
| 383 | input, |
| 384 | output, |
| 385 | descriptor); |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 386 | } |
| 387 | |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 388 | bool ClLayerSupport::IsMemCopySupported(const TensorInfo &input, |
| 389 | const TensorInfo &output, |
| 390 | Optional<std::string &> reasonIfUnsupported) const |
| 391 | { |
| 392 | ignore_unused(input); |
| 393 | ignore_unused(output); |
| 394 | return true; |
| 395 | } |
| 396 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 397 | bool ClLayerSupport::IsMergerSupported(const std::vector<const TensorInfo*> inputs, |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 398 | const TensorInfo& output, |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 399 | const OriginsDescriptor& descriptor, |
| 400 | Optional<std::string&> reasonIfUnsupported) const |
| 401 | { |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 402 | if(descriptor.GetNumDimensions() - descriptor.GetConcatAxis() == 1) |
| 403 | { |
| 404 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMergerWorkloadValidate, |
| 405 | reasonIfUnsupported, |
| 406 | inputs, |
| 407 | output, |
| 408 | descriptor); |
| 409 | } |
| 410 | else |
| 411 | { |
| 412 | return IsSupportedForDataTypeCl(reasonIfUnsupported, |
| 413 | inputs[0]->GetDataType(), |
| 414 | &TrueFunc<>, |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 415 | &TrueFunc<>); |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 416 | } |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 417 | } |
| 418 | |
saoste01 | 9292aa3 | 2019-01-08 13:55:59 +0000 | [diff] [blame] | 419 | bool ClLayerSupport::IsMinimumSupported(const TensorInfo& input0, |
| 420 | const TensorInfo& input1, |
| 421 | const TensorInfo& output, |
| 422 | Optional<std::string&> reasonIfUnsupported) const |
| 423 | { |
| 424 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMinimumWorkloadValidate, |
| 425 | reasonIfUnsupported, |
| 426 | input0, |
| 427 | input1, |
| 428 | output); |
| 429 | } |
| 430 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 431 | bool ClLayerSupport::IsMultiplicationSupported(const TensorInfo& input0, |
| 432 | const TensorInfo& input1, |
| 433 | const TensorInfo& output, |
| 434 | Optional<std::string&> reasonIfUnsupported) const |
| 435 | { |
| 436 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMultiplicationWorkloadValidate, |
| 437 | reasonIfUnsupported, |
| 438 | input0, |
| 439 | input1, |
| 440 | output); |
| 441 | } |
| 442 | |
| 443 | bool ClLayerSupport::IsNormalizationSupported(const TensorInfo& input, |
| 444 | const TensorInfo& output, |
| 445 | const NormalizationDescriptor& descriptor, |
| 446 | Optional<std::string&> reasonIfUnsupported) const |
| 447 | { |
| 448 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClNormalizationWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 449 | } |
| 450 | |
| 451 | bool ClLayerSupport::IsOutputSupported(const TensorInfo& output, |
| 452 | Optional<std::string&> reasonIfUnsupported) const |
| 453 | { |
| 454 | return IsSupportedForDataTypeCl(reasonIfUnsupported, |
| 455 | output.GetDataType(), |
| 456 | &TrueFunc<>, |
| 457 | &TrueFunc<>); |
| 458 | } |
| 459 | |
| 460 | bool ClLayerSupport::IsPadSupported(const TensorInfo& input, |
| 461 | const TensorInfo& output, |
| 462 | const PadDescriptor& descriptor, |
| 463 | Optional<std::string&> reasonIfUnsupported) const |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 464 | { |
| 465 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPadValidate, |
| 466 | reasonIfUnsupported, |
| 467 | input, |
| 468 | output, |
| 469 | descriptor); |
| 470 | } |
| 471 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 472 | bool ClLayerSupport::IsPermuteSupported(const TensorInfo& input, |
| 473 | const TensorInfo& output, |
| 474 | const PermuteDescriptor& descriptor, |
| 475 | Optional<std::string&> reasonIfUnsupported) const |
| 476 | { |
| 477 | ignore_unused(input); |
| 478 | ignore_unused(output); |
| 479 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPermuteWorkloadValidate, reasonIfUnsupported, descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 480 | } |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 481 | |
| 482 | bool ClLayerSupport::IsPooling2dSupported(const TensorInfo& input, |
| 483 | const TensorInfo& output, |
| 484 | const Pooling2dDescriptor& descriptor, |
| 485 | Optional<std::string&> reasonIfUnsupported) const |
| 486 | { |
| 487 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPooling2dWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 488 | } |
| 489 | |
| 490 | bool ClLayerSupport::IsReshapeSupported(const TensorInfo& input, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 491 | const ReshapeDescriptor& descriptor, |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 492 | Optional<std::string&> reasonIfUnsupported) const |
| 493 | { |
| 494 | ignore_unused(input); |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 495 | ignore_unused(descriptor); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 496 | ignore_unused(reasonIfUnsupported); |
| 497 | return true; |
| 498 | } |
| 499 | |
| 500 | bool ClLayerSupport::IsResizeBilinearSupported(const TensorInfo& input, |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame^] | 501 | const TensorInfo& output, |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 502 | Optional<std::string&> reasonIfUnsupported) const |
| 503 | { |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame^] | 504 | ignore_unused(output); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 505 | return IsSupportedForDataTypeCl(reasonIfUnsupported, |
| 506 | input.GetDataType(), |
| 507 | &TrueFunc<>, |
| 508 | &FalseFuncU8<>); |
| 509 | } |
| 510 | |
| 511 | bool ClLayerSupport::IsSoftmaxSupported(const TensorInfo& input, |
| 512 | const TensorInfo& output, |
| 513 | const SoftmaxDescriptor& descriptor, |
| 514 | Optional<std::string&> reasonIfUnsupported) const |
| 515 | { |
| 516 | ignore_unused(descriptor); |
| 517 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSoftmaxWorkloadValidate, reasonIfUnsupported, input, output); |
| 518 | } |
| 519 | |
Sadik Armagan | f446432 | 2018-12-20 16:19:12 +0000 | [diff] [blame] | 520 | bool ClLayerSupport::IsSpaceToBatchNdSupported(const TensorInfo& input, |
| 521 | const TensorInfo& output, |
| 522 | const SpaceToBatchNdDescriptor& descriptor, |
| 523 | Optional<std::string&> reasonIfUnsupported) const |
| 524 | { |
| 525 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSpaceToBatchNdWorkloadValidate, |
| 526 | reasonIfUnsupported, |
| 527 | input, |
| 528 | output, |
| 529 | descriptor); |
| 530 | } |
| 531 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 532 | bool ClLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 533 | const ViewsDescriptor& descriptor, |
| 534 | Optional<std::string&> reasonIfUnsupported) const |
| 535 | { |
| 536 | ignore_unused(descriptor); |
| 537 | return IsSupportedForDataTypeCl(reasonIfUnsupported, |
| 538 | input.GetDataType(), |
| 539 | &TrueFunc<>, |
| 540 | &TrueFunc<>); |
| 541 | } |
| 542 | |
keidav01 | d74dc91 | 2018-12-10 18:16:07 +0000 | [diff] [blame] | 543 | bool ClLayerSupport::IsStridedSliceSupported(const TensorInfo& input, |
| 544 | const TensorInfo& output, |
| 545 | const StridedSliceDescriptor& descriptor, |
| 546 | Optional<std::string&> reasonIfUnsupported) const |
| 547 | { |
| 548 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClStridedSliceWorkloadValidate, |
| 549 | reasonIfUnsupported, |
| 550 | input, |
| 551 | output, |
| 552 | descriptor); |
| 553 | } |
| 554 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 555 | bool ClLayerSupport::IsSubtractionSupported(const TensorInfo& input0, |
| 556 | const TensorInfo& input1, |
| 557 | const TensorInfo& output, |
| 558 | Optional<std::string&> reasonIfUnsupported) const |
| 559 | { |
| 560 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSubtractionValidate, |
| 561 | reasonIfUnsupported, |
| 562 | input0, |
| 563 | input1, |
| 564 | output); |
| 565 | } |
| 566 | |
| 567 | } // namespace armnn |