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