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