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 | { |
Francis Murtagh | 52ec346 | 2019-11-19 12:24:19 +0000 | [diff] [blame] | 187 | if (input.GetDataType() == DataType::QuantisedAsymm8) |
| 188 | { |
| 189 | return false; |
| 190 | } |
| 191 | |
James Conroy | 2dc0572 | 2019-09-19 17:00:31 +0100 | [diff] [blame] | 192 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClArgMinMaxWorkloadValidate, |
| 193 | reasonIfUnsupported, |
| 194 | input, |
| 195 | output, |
| 196 | descriptor); |
| 197 | } |
| 198 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 199 | bool ClLayerSupport::IsBatchNormalizationSupported(const TensorInfo& input, |
| 200 | const TensorInfo& output, |
| 201 | const TensorInfo& mean, |
| 202 | const TensorInfo& var, |
| 203 | const TensorInfo& beta, |
| 204 | const TensorInfo& gamma, |
| 205 | const BatchNormalizationDescriptor& descriptor, |
| 206 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 207 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 208 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClBatchNormalizationValidate, |
| 209 | reasonIfUnsupported, |
| 210 | input, |
| 211 | output, |
| 212 | mean, |
| 213 | var, |
| 214 | beta, |
| 215 | gamma, |
| 216 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 217 | } |
| 218 | |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 219 | bool ClLayerSupport::IsBatchToSpaceNdSupported(const TensorInfo& input, |
| 220 | const TensorInfo& output, |
| 221 | const BatchToSpaceNdDescriptor& descriptor, |
| 222 | Optional<std::string&> reasonIfUnsupported) const |
| 223 | { |
| 224 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClBatchToSpaceNdWorkloadValidate, |
| 225 | reasonIfUnsupported, |
| 226 | input, |
| 227 | output, |
| 228 | descriptor); |
| 229 | } |
| 230 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 231 | bool ClLayerSupport::IsComparisonSupported(const TensorInfo& input0, |
| 232 | const TensorInfo& input1, |
| 233 | const TensorInfo& output, |
| 234 | const ComparisonDescriptor& descriptor, |
| 235 | Optional<std::string&> reasonIfUnsupported) const |
| 236 | { |
| 237 | if (descriptor.m_Operation == ComparisonOperation::Greater) |
| 238 | { |
| 239 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClGreaterWorkloadValidate, |
| 240 | reasonIfUnsupported, |
| 241 | input0, |
| 242 | input1, |
| 243 | output); |
| 244 | } |
| 245 | |
| 246 | return false; |
| 247 | } |
| 248 | |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 249 | bool ClLayerSupport::IsConcatSupported(const std::vector<const TensorInfo*> inputs, |
| 250 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 251 | const ConcatDescriptor& descriptor, |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 252 | Optional<std::string&> reasonIfUnsupported) const |
| 253 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 254 | if (descriptor.GetNumDimensions() <= descriptor.GetConcatAxis()) |
| 255 | { |
| 256 | SetValueChecked(reasonIfUnsupported, "Cl Concat: Concat axis > Number of dimensions."); |
| 257 | return false; |
| 258 | } |
| 259 | |
| 260 | unsigned int concatInnerAxis = (descriptor.GetNumDimensions() - descriptor.GetConcatAxis()) - 1; |
| 261 | if(concatInnerAxis < 3) // Width, height, or channels |
| 262 | { |
| 263 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConcatWorkloadValidate, |
| 264 | reasonIfUnsupported, |
| 265 | inputs, |
| 266 | output, |
| 267 | descriptor); |
| 268 | } |
| 269 | else if (concatInnerAxis == 3) |
| 270 | { |
| 271 | // We rely on the sub-tensor optimization to handle the batch dimension for 4D tensors. If we can't use |
| 272 | // sub-tensors for this then we can't support it. Here is where we check that the sub-tensors will work. |
| 273 | for (auto& input : inputs) |
| 274 | { |
| 275 | if (input && !output.IsTypeSpaceMatch(*input)) // Cannot use sub-tensors if the types are not same space |
| 276 | { |
| 277 | SetValueChecked(reasonIfUnsupported, "Cl Concat: Types and quantization parameters must match."); |
| 278 | return false; |
| 279 | } |
| 280 | } |
| 281 | return true; // Sub-tensors support concat along batch |
| 282 | } |
| 283 | else // > 4 dimensions not supported. |
| 284 | { |
| 285 | SetValueChecked(reasonIfUnsupported, "Cl Concat: Maximum of 4 dimensions supported."); |
| 286 | return false; |
| 287 | } |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 288 | } |
| 289 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 290 | bool ClLayerSupport::IsConstantSupported(const TensorInfo& output, |
| 291 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 292 | { |
| 293 | return IsSupportedForDataTypeCl(reasonIfUnsupported, |
| 294 | output.GetDataType(), |
| 295 | &TrueFunc<>, |
Francis Murtagh | ec33a91 | 2019-11-05 14:26:23 +0000 | [diff] [blame] | 296 | &TrueFunc<>); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 297 | } |
| 298 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 299 | bool ClLayerSupport::IsConvertFp16ToFp32Supported(const TensorInfo& input, |
| 300 | const TensorInfo& output, |
| 301 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 302 | { |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 303 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConvertFp16ToFp32WorkloadValidate, |
| 304 | reasonIfUnsupported, |
| 305 | input, |
| 306 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 307 | } |
| 308 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 309 | bool ClLayerSupport::IsConvertFp32ToFp16Supported(const TensorInfo& input, |
| 310 | const TensorInfo& output, |
| 311 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 312 | { |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 313 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConvertFp32ToFp16WorkloadValidate, |
| 314 | reasonIfUnsupported, |
| 315 | input, |
| 316 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 317 | } |
| 318 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 319 | bool ClLayerSupport::IsConvolution2dSupported(const TensorInfo& input, |
| 320 | const TensorInfo& output, |
| 321 | const Convolution2dDescriptor& descriptor, |
| 322 | const TensorInfo& weights, |
| 323 | const Optional<TensorInfo>& biases, |
| 324 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 325 | { |
Aron Virginas-Tar | 07f25e0 | 2019-11-07 15:19:52 +0000 | [diff] [blame] | 326 | if (weights.HasPerAxisQuantization()) |
| 327 | { |
| 328 | return false; |
| 329 | } |
| 330 | |
James Conroy | b86a382 | 2019-11-19 15:28:58 +0000 | [diff] [blame] | 331 | // Multiplier > 1.0f currently not supported in ACL |
| 332 | if ((input.GetQuantizationScale() * weights.GetQuantizationScale()) / output.GetQuantizationScale() > 1.0f) |
| 333 | { |
| 334 | return false; |
| 335 | } |
| 336 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 337 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConvolution2dWorkloadValidate, |
| 338 | reasonIfUnsupported, |
| 339 | input, |
| 340 | output, |
| 341 | descriptor, |
| 342 | weights, |
| 343 | biases); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 344 | } |
| 345 | |
Jim Flynn | 983daec | 2019-05-29 16:20:16 +0100 | [diff] [blame] | 346 | bool ClLayerSupport::IsDequantizeSupported(const TensorInfo& input, |
| 347 | const TensorInfo& output, |
| 348 | Optional<std::string&> reasonIfUnsupported) const |
| 349 | { |
| 350 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDequantizeWorkloadValidate, |
| 351 | reasonIfUnsupported, |
| 352 | input, |
| 353 | output); |
| 354 | } |
| 355 | |
Aron Virginas-Tar | b280196 | 2019-09-30 11:24:53 +0100 | [diff] [blame] | 356 | bool ClLayerSupport::IsDepthToSpaceSupported(const TensorInfo& input, |
| 357 | const TensorInfo& output, |
| 358 | const DepthToSpaceDescriptor& descriptor, |
| 359 | Optional<std::string&> reasonIfUnsupported) const |
| 360 | { |
| 361 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDepthToSpaceWorkloadValidate, |
| 362 | reasonIfUnsupported, |
| 363 | input, |
| 364 | output, |
| 365 | descriptor); |
| 366 | } |
| 367 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 368 | bool ClLayerSupport::IsDepthwiseConvolutionSupported(const TensorInfo& input, |
| 369 | const TensorInfo& output, |
| 370 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 371 | const TensorInfo& weights, |
| 372 | const Optional<TensorInfo>& biases, |
| 373 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 374 | { |
Aron Virginas-Tar | 5716de2 | 2019-11-15 10:22:28 +0000 | [diff] [blame] | 375 | if (weights.HasPerAxisQuantization()) |
| 376 | { |
| 377 | return false; |
| 378 | } |
| 379 | |
James Conroy | b86a382 | 2019-11-19 15:28:58 +0000 | [diff] [blame] | 380 | // Multiplier > 1.0f currently not supported in ACL |
| 381 | if ((input.GetQuantizationScale() * weights.GetQuantizationScale()) / output.GetQuantizationScale() > 1.0f) |
| 382 | { |
| 383 | return false; |
| 384 | } |
| 385 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 386 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDepthwiseConvolutionWorkloadValidate, |
| 387 | reasonIfUnsupported, |
| 388 | input, |
| 389 | output, |
| 390 | descriptor, |
| 391 | weights, |
| 392 | biases); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 393 | } |
| 394 | |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 395 | bool ClLayerSupport::IsDilatedDepthwiseConvolutionSupported(const TensorInfo& input, |
| 396 | const TensorInfo& output, |
| 397 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 398 | const TensorInfo& weights, |
| 399 | const Optional<TensorInfo>& biases, |
| 400 | Optional<std::string&> reasonIfUnsupported) const |
| 401 | { |
James Conroy | b86a382 | 2019-11-19 15:28:58 +0000 | [diff] [blame] | 402 | // Multiplier > 1.0f currently not supported in ACL |
| 403 | if ((input.GetQuantizationScale() * weights.GetQuantizationScale()) / output.GetQuantizationScale() > 1.0f) |
| 404 | { |
| 405 | return false; |
| 406 | } |
| 407 | |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 408 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDepthwiseConvolutionWorkloadValidate, |
| 409 | reasonIfUnsupported, |
| 410 | input, |
| 411 | output, |
| 412 | descriptor, |
| 413 | weights, |
| 414 | biases); |
| 415 | } |
| 416 | |
| 417 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 418 | bool ClLayerSupport::IsDivisionSupported(const TensorInfo& input0, |
| 419 | const TensorInfo& input1, |
| 420 | const TensorInfo& output, |
| 421 | Optional<std::string&> reasonIfUnsupported) const |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 422 | { |
| 423 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDivisionWorkloadValidate, |
| 424 | reasonIfUnsupported, |
| 425 | input0, |
| 426 | input1, |
| 427 | output); |
| 428 | } |
| 429 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 430 | bool ClLayerSupport::IsFloorSupported(const TensorInfo& input, |
| 431 | const TensorInfo& output, |
| 432 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 433 | { |
Sadik Armagan | 9be4916 | 2019-10-30 16:15:26 +0000 | [diff] [blame] | 434 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClFloorWorkloadValidate, |
| 435 | reasonIfUnsupported, |
| 436 | input, |
| 437 | output); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 438 | } |
| 439 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 440 | bool ClLayerSupport::IsFullyConnectedSupported(const TensorInfo& input, |
| 441 | const TensorInfo& output, |
| 442 | const TensorInfo& weights, |
| 443 | const TensorInfo& biases, |
| 444 | const FullyConnectedDescriptor& descriptor, |
| 445 | Optional<std::string&> reasonIfUnsupported) const |
| 446 | { |
| 447 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClFullyConnectedWorkloadValidate, |
| 448 | reasonIfUnsupported, |
| 449 | input, |
| 450 | output, |
| 451 | weights, |
| 452 | biases, |
| 453 | descriptor); |
| 454 | } |
| 455 | |
Nattapat Chaimanowong | c6a41ff | 2019-01-29 09:56:02 +0000 | [diff] [blame] | 456 | bool ClLayerSupport::IsGreaterSupported(const TensorInfo& input0, |
| 457 | const TensorInfo& input1, |
| 458 | const TensorInfo& output, |
| 459 | Optional<std::string&> reasonIfUnsupported) const |
| 460 | { |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 461 | ComparisonDescriptor descriptor(ComparisonOperation::Greater); |
| 462 | return IsComparisonSupported(input0, input1, output, descriptor, reasonIfUnsupported); |
Nattapat Chaimanowong | c6a41ff | 2019-01-29 09:56:02 +0000 | [diff] [blame] | 463 | } |
| 464 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 465 | bool ClLayerSupport::IsInputSupported(const TensorInfo& input, |
| 466 | Optional<std::string&> reasonIfUnsupported) const |
| 467 | { |
Francis Murtagh | b3fc252 | 2019-08-09 13:20:50 +0100 | [diff] [blame] | 468 | return IsClBackendSupported(reasonIfUnsupported); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 469 | } |
| 470 | |
Aron Virginas-Tar | 8168f40 | 2019-10-04 13:10:16 +0100 | [diff] [blame] | 471 | bool ClLayerSupport::IsInstanceNormalizationSupported(const TensorInfo& input, |
| 472 | const TensorInfo& output, |
| 473 | const InstanceNormalizationDescriptor& descriptor, |
| 474 | Optional<std::string&> reasonIfUnsupported) const |
| 475 | { |
| 476 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClInstanceNormalizationWorkloadValidate, |
| 477 | reasonIfUnsupported, |
| 478 | input, |
| 479 | output, |
| 480 | descriptor); |
| 481 | } |
| 482 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 483 | bool ClLayerSupport::IsL2NormalizationSupported(const TensorInfo& input, |
| 484 | const TensorInfo& output, |
| 485 | const L2NormalizationDescriptor& descriptor, |
| 486 | Optional<std::string&> reasonIfUnsupported) const |
| 487 | { |
| 488 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClL2NormalizationWorkloadValidate, |
| 489 | reasonIfUnsupported, |
| 490 | input, |
| 491 | output, |
| 492 | descriptor); |
| 493 | } |
| 494 | |
| 495 | bool ClLayerSupport::IsLstmSupported(const TensorInfo& input, |
| 496 | const TensorInfo& outputStateIn, |
| 497 | const TensorInfo& cellStateIn, |
| 498 | const TensorInfo& scratchBuffer, |
| 499 | const TensorInfo& outputStateOut, |
| 500 | const TensorInfo& cellStateOut, |
| 501 | const TensorInfo& output, |
| 502 | const LstmDescriptor& descriptor, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 503 | const LstmInputParamsInfo& paramsInfo, |
| 504 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 505 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 506 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClLstmFloatWorkloadValidate, |
| 507 | reasonIfUnsupported, |
| 508 | input, |
| 509 | outputStateIn, |
| 510 | cellStateIn, |
| 511 | scratchBuffer, |
| 512 | outputStateOut, |
| 513 | cellStateOut, |
| 514 | output, |
| 515 | descriptor, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 516 | paramsInfo); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 517 | } |
| 518 | |
keidav01 | a959ee5 | 2018-12-19 10:04:58 +0000 | [diff] [blame] | 519 | bool ClLayerSupport::IsMaximumSupported(const TensorInfo& input0, |
| 520 | const TensorInfo& input1, |
| 521 | const TensorInfo& output, |
| 522 | Optional<std::string&> reasonIfUnsupported) const |
| 523 | { |
| 524 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMaximumWorkloadValidate, |
| 525 | reasonIfUnsupported, |
| 526 | input0, |
| 527 | input1, |
| 528 | output); |
| 529 | } |
| 530 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 531 | bool ClLayerSupport::IsMeanSupported(const TensorInfo& input, |
| 532 | const TensorInfo& output, |
| 533 | const MeanDescriptor& descriptor, |
| 534 | Optional<std::string&> reasonIfUnsupported) const |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 535 | { |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 536 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMeanValidate, |
| 537 | reasonIfUnsupported, |
| 538 | input, |
| 539 | output, |
| 540 | descriptor); |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 541 | } |
| 542 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 543 | bool ClLayerSupport::IsMergerSupported(const std::vector<const TensorInfo*> inputs, |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 544 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 545 | const MergerDescriptor& descriptor, |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 546 | Optional<std::string&> reasonIfUnsupported) const |
| 547 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 548 | return IsConcatSupported(inputs, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 549 | } |
| 550 | |
saoste01 | 9292aa3 | 2019-01-08 13:55:59 +0000 | [diff] [blame] | 551 | bool ClLayerSupport::IsMinimumSupported(const TensorInfo& input0, |
| 552 | const TensorInfo& input1, |
| 553 | const TensorInfo& output, |
| 554 | Optional<std::string&> reasonIfUnsupported) const |
| 555 | { |
| 556 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMinimumWorkloadValidate, |
| 557 | reasonIfUnsupported, |
| 558 | input0, |
| 559 | input1, |
| 560 | output); |
| 561 | } |
| 562 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 563 | bool ClLayerSupport::IsMultiplicationSupported(const TensorInfo& input0, |
| 564 | const TensorInfo& input1, |
| 565 | const TensorInfo& output, |
| 566 | Optional<std::string&> reasonIfUnsupported) const |
| 567 | { |
| 568 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMultiplicationWorkloadValidate, |
| 569 | reasonIfUnsupported, |
| 570 | input0, |
| 571 | input1, |
| 572 | output); |
| 573 | } |
| 574 | |
| 575 | bool ClLayerSupport::IsNormalizationSupported(const TensorInfo& input, |
| 576 | const TensorInfo& output, |
| 577 | const NormalizationDescriptor& descriptor, |
| 578 | Optional<std::string&> reasonIfUnsupported) const |
| 579 | { |
| 580 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClNormalizationWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 581 | } |
| 582 | |
| 583 | bool ClLayerSupport::IsOutputSupported(const TensorInfo& output, |
| 584 | Optional<std::string&> reasonIfUnsupported) const |
| 585 | { |
Francis Murtagh | b3fc252 | 2019-08-09 13:20:50 +0100 | [diff] [blame] | 586 | return IsClBackendSupported(reasonIfUnsupported); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 587 | } |
| 588 | |
| 589 | bool ClLayerSupport::IsPadSupported(const TensorInfo& input, |
| 590 | const TensorInfo& output, |
| 591 | const PadDescriptor& descriptor, |
| 592 | Optional<std::string&> reasonIfUnsupported) const |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 593 | { |
| 594 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPadValidate, |
| 595 | reasonIfUnsupported, |
| 596 | input, |
| 597 | output, |
| 598 | descriptor); |
| 599 | } |
| 600 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 601 | bool ClLayerSupport::IsPermuteSupported(const TensorInfo& input, |
| 602 | const TensorInfo& output, |
| 603 | const PermuteDescriptor& descriptor, |
| 604 | Optional<std::string&> reasonIfUnsupported) const |
| 605 | { |
| 606 | ignore_unused(input); |
| 607 | ignore_unused(output); |
| 608 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPermuteWorkloadValidate, reasonIfUnsupported, descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 609 | } |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 610 | |
| 611 | bool ClLayerSupport::IsPooling2dSupported(const TensorInfo& input, |
| 612 | const TensorInfo& output, |
| 613 | const Pooling2dDescriptor& descriptor, |
| 614 | Optional<std::string&> reasonIfUnsupported) const |
| 615 | { |
| 616 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPooling2dWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 617 | } |
| 618 | |
Nikhil Raj | 91e4c6d | 2019-07-05 12:22:58 +0100 | [diff] [blame] | 619 | bool ClLayerSupport::IsPreluSupported(const armnn::TensorInfo &input, |
| 620 | const armnn::TensorInfo &alpha, |
| 621 | const armnn::TensorInfo &output, |
| 622 | armnn::Optional<std::string &> reasonIfUnsupported) const |
| 623 | { |
| 624 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPreluWorkloadValidate, reasonIfUnsupported, input, alpha, output); |
| 625 | } |
| 626 | |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 627 | bool ClLayerSupport::IsQuantizedLstmSupported(const TensorInfo& input, |
| 628 | const TensorInfo& previousCellStateIn, |
| 629 | const TensorInfo& previousOutputIn, |
| 630 | const TensorInfo& cellStateOut, |
| 631 | const TensorInfo& output, |
| 632 | const QuantizedLstmInputParamsInfo& paramsInfo, |
| 633 | Optional<std::string&> reasonIfUnsupported) const |
| 634 | { |
| 635 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClQuantizedLstmWorkloadValidate, |
| 636 | reasonIfUnsupported, |
| 637 | input, |
| 638 | previousCellStateIn, |
| 639 | previousOutputIn, |
| 640 | cellStateOut, |
| 641 | output, |
| 642 | paramsInfo); |
| 643 | } |
| 644 | |
Sadik Armagan | 20ec249 | 2019-05-31 09:09:44 +0100 | [diff] [blame] | 645 | bool ClLayerSupport::IsQuantizeSupported(const TensorInfo& input, |
| 646 | const TensorInfo& output, |
| 647 | Optional<std::string&> reasonIfUnsupported) const |
| 648 | { |
| 649 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClQuantizeWorkloadValidate, |
| 650 | reasonIfUnsupported, |
| 651 | input, |
| 652 | output); |
| 653 | } |
| 654 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 655 | bool ClLayerSupport::IsReshapeSupported(const TensorInfo& input, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 656 | const ReshapeDescriptor& descriptor, |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 657 | Optional<std::string&> reasonIfUnsupported) const |
| 658 | { |
| 659 | ignore_unused(input); |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 660 | ignore_unused(descriptor); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 661 | ignore_unused(reasonIfUnsupported); |
| 662 | return true; |
| 663 | } |
| 664 | |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 665 | bool ClLayerSupport::IsResizeSupported(const TensorInfo& input, |
| 666 | const TensorInfo& output, |
| 667 | const ResizeDescriptor& descriptor, |
| 668 | Optional<std::string&> reasonIfUnsupported) const |
| 669 | { |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 670 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClResizeWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 671 | } |
| 672 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 673 | bool ClLayerSupport::IsResizeBilinearSupported(const TensorInfo& input, |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame] | 674 | const TensorInfo& output, |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 675 | Optional<std::string&> reasonIfUnsupported) const |
| 676 | { |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 677 | ResizeDescriptor descriptor; |
| 678 | descriptor.m_Method = ResizeMethod::Bilinear; |
| 679 | descriptor.m_DataLayout = DataLayout::NCHW; |
| 680 | |
| 681 | const TensorShape& outputShape = output.GetShape(); |
| 682 | descriptor.m_TargetHeight = outputShape[2]; |
| 683 | descriptor.m_TargetWidth = outputShape[3]; |
| 684 | |
| 685 | return IsResizeSupported(input, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 686 | } |
| 687 | |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 688 | bool ClLayerSupport::IsRsqrtSupported(const TensorInfo& input, |
| 689 | const TensorInfo& output, |
| 690 | Optional<std::string&> reasonIfUnsupported) const |
| 691 | { |
| 692 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClRsqrtWorkloadValidate, reasonIfUnsupported, input, output); |
| 693 | } |
| 694 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 695 | bool ClLayerSupport::IsSoftmaxSupported(const TensorInfo& input, |
| 696 | const TensorInfo& output, |
| 697 | const SoftmaxDescriptor& descriptor, |
| 698 | Optional<std::string&> reasonIfUnsupported) const |
| 699 | { |
Francis Murtagh | 3b93835 | 2019-07-26 15:44:17 +0100 | [diff] [blame] | 700 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSoftmaxWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 701 | } |
| 702 | |
Sadik Armagan | f446432 | 2018-12-20 16:19:12 +0000 | [diff] [blame] | 703 | bool ClLayerSupport::IsSpaceToBatchNdSupported(const TensorInfo& input, |
| 704 | const TensorInfo& output, |
| 705 | const SpaceToBatchNdDescriptor& descriptor, |
| 706 | Optional<std::string&> reasonIfUnsupported) const |
| 707 | { |
| 708 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSpaceToBatchNdWorkloadValidate, |
| 709 | reasonIfUnsupported, |
| 710 | input, |
| 711 | output, |
| 712 | descriptor); |
| 713 | } |
| 714 | |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 715 | bool ClLayerSupport::IsSpaceToDepthSupported(const TensorInfo& input, |
| 716 | const TensorInfo& output, |
| 717 | const SpaceToDepthDescriptor& descriptor, |
| 718 | Optional<std::string&> reasonIfUnsupported) const |
| 719 | { |
| 720 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSpaceToDepthWorkloadValidate, |
| 721 | reasonIfUnsupported, |
| 722 | input, |
| 723 | output, |
| 724 | descriptor); |
| 725 | } |
| 726 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 727 | bool ClLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 728 | const ViewsDescriptor& descriptor, |
| 729 | Optional<std::string&> reasonIfUnsupported) const |
| 730 | { |
| 731 | ignore_unused(descriptor); |
| 732 | return IsSupportedForDataTypeCl(reasonIfUnsupported, |
| 733 | input.GetDataType(), |
| 734 | &TrueFunc<>, |
| 735 | &TrueFunc<>); |
| 736 | } |
| 737 | |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 738 | bool ClLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 739 | const std::vector<std::reference_wrapper<TensorInfo>>& outputs, |
| 740 | const ViewsDescriptor& descriptor, |
| 741 | Optional<std::string&> reasonIfUnsupported) const |
| 742 | { |
Narumol Prangnawarat | 7413583 | 2019-05-23 15:07:33 +0100 | [diff] [blame] | 743 | #if defined(ARMCOMPUTECL_ENABLED) |
| 744 | // Split along the last dimension, cannot use sub-tensors |
| 745 | // as width and height of the sub-tensors do not match |
| 746 | // the width and height of the parent tensor |
| 747 | // in case of input with more than 2D. |
| 748 | std::set<unsigned int> splitAxis = ComputeSplitAxis(descriptor, input.GetShape()); |
| 749 | if (descriptor.GetNumDimensions() > 2 && splitAxis.size() == 1 && |
| 750 | *splitAxis.begin() == descriptor.GetNumDimensions() - 1 ) |
| 751 | { |
| 752 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSplitterWorkloadValidate, |
| 753 | reasonIfUnsupported, |
| 754 | input, |
| 755 | outputs, |
| 756 | *splitAxis.begin()); |
| 757 | } |
| 758 | #endif |
| 759 | for (auto output : outputs) |
| 760 | { |
| 761 | if (!input.IsTypeSpaceMatch(output)) // Cannot use sub-tensors if the types are not same space |
| 762 | { |
| 763 | SetValueChecked(reasonIfUnsupported, "Cl Splitter: Types and quantization parameters must match."); |
| 764 | return false; |
| 765 | } |
| 766 | } |
| 767 | return true; |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 768 | } |
| 769 | |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 770 | bool ClLayerSupport::IsStackSupported(const std::vector<const TensorInfo*>& inputs, |
| 771 | const TensorInfo& output, |
| 772 | const StackDescriptor& descriptor, |
| 773 | Optional<std::string&> reasonIfUnsupported) const |
| 774 | { |
| 775 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClStackWorkloadValidate, |
| 776 | reasonIfUnsupported, |
| 777 | inputs, |
| 778 | output, |
| 779 | descriptor); |
| 780 | } |
| 781 | |
keidav01 | d74dc91 | 2018-12-10 18:16:07 +0000 | [diff] [blame] | 782 | bool ClLayerSupport::IsStridedSliceSupported(const TensorInfo& input, |
| 783 | const TensorInfo& output, |
| 784 | const StridedSliceDescriptor& descriptor, |
| 785 | Optional<std::string&> reasonIfUnsupported) const |
| 786 | { |
| 787 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClStridedSliceWorkloadValidate, |
| 788 | reasonIfUnsupported, |
| 789 | input, |
| 790 | output, |
| 791 | descriptor); |
| 792 | } |
| 793 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 794 | bool ClLayerSupport::IsSubtractionSupported(const TensorInfo& input0, |
| 795 | const TensorInfo& input1, |
| 796 | const TensorInfo& output, |
| 797 | Optional<std::string&> reasonIfUnsupported) const |
| 798 | { |
| 799 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSubtractionValidate, |
| 800 | reasonIfUnsupported, |
| 801 | input0, |
| 802 | input1, |
| 803 | output); |
| 804 | } |
| 805 | |
Aron Virginas-Tar | 7a3e2fe | 2019-06-27 18:54:47 +0100 | [diff] [blame] | 806 | bool ClLayerSupport::IsTransposeConvolution2dSupported(const TensorInfo& input, |
| 807 | const TensorInfo& output, |
| 808 | const TransposeConvolution2dDescriptor& descriptor, |
| 809 | const TensorInfo& weights, |
| 810 | const Optional<TensorInfo>& biases, |
| 811 | Optional<std::string&> reasonIfUnsupported) const |
| 812 | { |
James Conroy | b86a382 | 2019-11-19 15:28:58 +0000 | [diff] [blame] | 813 | // Multiplier > 1.0f currently not supported in ACL |
| 814 | if ((input.GetQuantizationScale() * weights.GetQuantizationScale()) / output.GetQuantizationScale() > 1.0f) |
| 815 | { |
| 816 | return false; |
| 817 | } |
| 818 | |
Aron Virginas-Tar | 7a3e2fe | 2019-06-27 18:54:47 +0100 | [diff] [blame] | 819 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClTransposeConvolution2dWorkloadValidate, |
| 820 | reasonIfUnsupported, |
| 821 | input, |
| 822 | output, |
| 823 | descriptor, |
| 824 | weights, |
| 825 | biases); |
| 826 | } |
| 827 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 828 | } // namespace armnn |