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