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