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