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