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 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 331 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConvolution2dWorkloadValidate, |
| 332 | reasonIfUnsupported, |
| 333 | input, |
| 334 | output, |
| 335 | descriptor, |
| 336 | weights, |
| 337 | biases); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 338 | } |
| 339 | |
Jim Flynn | 983daec | 2019-05-29 16:20:16 +0100 | [diff] [blame] | 340 | bool ClLayerSupport::IsDequantizeSupported(const TensorInfo& input, |
| 341 | const TensorInfo& output, |
| 342 | Optional<std::string&> reasonIfUnsupported) const |
| 343 | { |
| 344 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDequantizeWorkloadValidate, |
| 345 | reasonIfUnsupported, |
| 346 | input, |
| 347 | output); |
| 348 | } |
| 349 | |
Aron Virginas-Tar | b280196 | 2019-09-30 11:24:53 +0100 | [diff] [blame] | 350 | bool ClLayerSupport::IsDepthToSpaceSupported(const TensorInfo& input, |
| 351 | const TensorInfo& output, |
| 352 | const DepthToSpaceDescriptor& descriptor, |
| 353 | Optional<std::string&> reasonIfUnsupported) const |
| 354 | { |
| 355 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDepthToSpaceWorkloadValidate, |
| 356 | reasonIfUnsupported, |
| 357 | input, |
| 358 | output, |
| 359 | descriptor); |
| 360 | } |
| 361 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 362 | bool ClLayerSupport::IsDepthwiseConvolutionSupported(const TensorInfo& input, |
| 363 | const TensorInfo& output, |
| 364 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 365 | const TensorInfo& weights, |
| 366 | const Optional<TensorInfo>& biases, |
| 367 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 368 | { |
Aron Virginas-Tar | 5716de2 | 2019-11-15 10:22:28 +0000 | [diff] [blame] | 369 | if (weights.HasPerAxisQuantization()) |
| 370 | { |
| 371 | return false; |
| 372 | } |
| 373 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 374 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDepthwiseConvolutionWorkloadValidate, |
| 375 | reasonIfUnsupported, |
| 376 | input, |
| 377 | output, |
| 378 | descriptor, |
| 379 | weights, |
| 380 | biases); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 381 | } |
| 382 | |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 383 | bool ClLayerSupport::IsDilatedDepthwiseConvolutionSupported(const TensorInfo& input, |
| 384 | const TensorInfo& output, |
| 385 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 386 | const TensorInfo& weights, |
| 387 | const Optional<TensorInfo>& biases, |
| 388 | Optional<std::string&> reasonIfUnsupported) const |
| 389 | { |
| 390 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDepthwiseConvolutionWorkloadValidate, |
| 391 | reasonIfUnsupported, |
| 392 | input, |
| 393 | output, |
| 394 | descriptor, |
| 395 | weights, |
| 396 | biases); |
| 397 | } |
| 398 | |
| 399 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 400 | bool ClLayerSupport::IsDivisionSupported(const TensorInfo& input0, |
| 401 | const TensorInfo& input1, |
| 402 | const TensorInfo& output, |
| 403 | Optional<std::string&> reasonIfUnsupported) const |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 404 | { |
| 405 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDivisionWorkloadValidate, |
| 406 | reasonIfUnsupported, |
| 407 | input0, |
| 408 | input1, |
| 409 | output); |
| 410 | } |
| 411 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 412 | bool ClLayerSupport::IsFloorSupported(const TensorInfo& input, |
| 413 | const TensorInfo& output, |
| 414 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 415 | { |
Sadik Armagan | 9be4916 | 2019-10-30 16:15:26 +0000 | [diff] [blame] | 416 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClFloorWorkloadValidate, |
| 417 | reasonIfUnsupported, |
| 418 | input, |
| 419 | output); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 420 | } |
| 421 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 422 | bool ClLayerSupport::IsFullyConnectedSupported(const TensorInfo& input, |
| 423 | const TensorInfo& output, |
| 424 | const TensorInfo& weights, |
| 425 | const TensorInfo& biases, |
| 426 | const FullyConnectedDescriptor& descriptor, |
| 427 | Optional<std::string&> reasonIfUnsupported) const |
| 428 | { |
| 429 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClFullyConnectedWorkloadValidate, |
| 430 | reasonIfUnsupported, |
| 431 | input, |
| 432 | output, |
| 433 | weights, |
| 434 | biases, |
| 435 | descriptor); |
| 436 | } |
| 437 | |
Nattapat Chaimanowong | c6a41ff | 2019-01-29 09:56:02 +0000 | [diff] [blame] | 438 | bool ClLayerSupport::IsGreaterSupported(const TensorInfo& input0, |
| 439 | const TensorInfo& input1, |
| 440 | const TensorInfo& output, |
| 441 | Optional<std::string&> reasonIfUnsupported) const |
| 442 | { |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 443 | ComparisonDescriptor descriptor(ComparisonOperation::Greater); |
| 444 | return IsComparisonSupported(input0, input1, output, descriptor, reasonIfUnsupported); |
Nattapat Chaimanowong | c6a41ff | 2019-01-29 09:56:02 +0000 | [diff] [blame] | 445 | } |
| 446 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 447 | bool ClLayerSupport::IsInputSupported(const TensorInfo& input, |
| 448 | Optional<std::string&> reasonIfUnsupported) const |
| 449 | { |
Francis Murtagh | b3fc252 | 2019-08-09 13:20:50 +0100 | [diff] [blame] | 450 | return IsClBackendSupported(reasonIfUnsupported); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 451 | } |
| 452 | |
Aron Virginas-Tar | 8168f40 | 2019-10-04 13:10:16 +0100 | [diff] [blame] | 453 | bool ClLayerSupport::IsInstanceNormalizationSupported(const TensorInfo& input, |
| 454 | const TensorInfo& output, |
| 455 | const InstanceNormalizationDescriptor& descriptor, |
| 456 | Optional<std::string&> reasonIfUnsupported) const |
| 457 | { |
| 458 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClInstanceNormalizationWorkloadValidate, |
| 459 | reasonIfUnsupported, |
| 460 | input, |
| 461 | output, |
| 462 | descriptor); |
| 463 | } |
| 464 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 465 | bool ClLayerSupport::IsL2NormalizationSupported(const TensorInfo& input, |
| 466 | const TensorInfo& output, |
| 467 | const L2NormalizationDescriptor& descriptor, |
| 468 | Optional<std::string&> reasonIfUnsupported) const |
| 469 | { |
| 470 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClL2NormalizationWorkloadValidate, |
| 471 | reasonIfUnsupported, |
| 472 | input, |
| 473 | output, |
| 474 | descriptor); |
| 475 | } |
| 476 | |
| 477 | bool ClLayerSupport::IsLstmSupported(const TensorInfo& input, |
| 478 | const TensorInfo& outputStateIn, |
| 479 | const TensorInfo& cellStateIn, |
| 480 | const TensorInfo& scratchBuffer, |
| 481 | const TensorInfo& outputStateOut, |
| 482 | const TensorInfo& cellStateOut, |
| 483 | const TensorInfo& output, |
| 484 | const LstmDescriptor& descriptor, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 485 | const LstmInputParamsInfo& paramsInfo, |
| 486 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 487 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 488 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClLstmFloatWorkloadValidate, |
| 489 | reasonIfUnsupported, |
| 490 | input, |
| 491 | outputStateIn, |
| 492 | cellStateIn, |
| 493 | scratchBuffer, |
| 494 | outputStateOut, |
| 495 | cellStateOut, |
| 496 | output, |
| 497 | descriptor, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 498 | paramsInfo); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 499 | } |
| 500 | |
keidav01 | a959ee5 | 2018-12-19 10:04:58 +0000 | [diff] [blame] | 501 | bool ClLayerSupport::IsMaximumSupported(const TensorInfo& input0, |
| 502 | const TensorInfo& input1, |
| 503 | const TensorInfo& output, |
| 504 | Optional<std::string&> reasonIfUnsupported) const |
| 505 | { |
| 506 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMaximumWorkloadValidate, |
| 507 | reasonIfUnsupported, |
| 508 | input0, |
| 509 | input1, |
| 510 | output); |
| 511 | } |
| 512 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 513 | bool ClLayerSupport::IsMeanSupported(const TensorInfo& input, |
| 514 | const TensorInfo& output, |
| 515 | const MeanDescriptor& descriptor, |
| 516 | Optional<std::string&> reasonIfUnsupported) const |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 517 | { |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 518 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMeanValidate, |
| 519 | reasonIfUnsupported, |
| 520 | input, |
| 521 | output, |
| 522 | descriptor); |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 523 | } |
| 524 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 525 | bool ClLayerSupport::IsMergerSupported(const std::vector<const TensorInfo*> inputs, |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 526 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 527 | const MergerDescriptor& descriptor, |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 528 | Optional<std::string&> reasonIfUnsupported) const |
| 529 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 530 | return IsConcatSupported(inputs, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 531 | } |
| 532 | |
saoste01 | 9292aa3 | 2019-01-08 13:55:59 +0000 | [diff] [blame] | 533 | bool ClLayerSupport::IsMinimumSupported(const TensorInfo& input0, |
| 534 | const TensorInfo& input1, |
| 535 | const TensorInfo& output, |
| 536 | Optional<std::string&> reasonIfUnsupported) const |
| 537 | { |
| 538 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMinimumWorkloadValidate, |
| 539 | reasonIfUnsupported, |
| 540 | input0, |
| 541 | input1, |
| 542 | output); |
| 543 | } |
| 544 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 545 | bool ClLayerSupport::IsMultiplicationSupported(const TensorInfo& input0, |
| 546 | const TensorInfo& input1, |
| 547 | const TensorInfo& output, |
| 548 | Optional<std::string&> reasonIfUnsupported) const |
| 549 | { |
| 550 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMultiplicationWorkloadValidate, |
| 551 | reasonIfUnsupported, |
| 552 | input0, |
| 553 | input1, |
| 554 | output); |
| 555 | } |
| 556 | |
| 557 | bool ClLayerSupport::IsNormalizationSupported(const TensorInfo& input, |
| 558 | const TensorInfo& output, |
| 559 | const NormalizationDescriptor& descriptor, |
| 560 | Optional<std::string&> reasonIfUnsupported) const |
| 561 | { |
| 562 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClNormalizationWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 563 | } |
| 564 | |
| 565 | bool ClLayerSupport::IsOutputSupported(const TensorInfo& output, |
| 566 | Optional<std::string&> reasonIfUnsupported) const |
| 567 | { |
Francis Murtagh | b3fc252 | 2019-08-09 13:20:50 +0100 | [diff] [blame] | 568 | return IsClBackendSupported(reasonIfUnsupported); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | bool ClLayerSupport::IsPadSupported(const TensorInfo& input, |
| 572 | const TensorInfo& output, |
| 573 | const PadDescriptor& descriptor, |
| 574 | Optional<std::string&> reasonIfUnsupported) const |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 575 | { |
| 576 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPadValidate, |
| 577 | reasonIfUnsupported, |
| 578 | input, |
| 579 | output, |
| 580 | descriptor); |
| 581 | } |
| 582 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 583 | bool ClLayerSupport::IsPermuteSupported(const TensorInfo& input, |
| 584 | const TensorInfo& output, |
| 585 | const PermuteDescriptor& descriptor, |
| 586 | Optional<std::string&> reasonIfUnsupported) const |
| 587 | { |
| 588 | ignore_unused(input); |
| 589 | ignore_unused(output); |
| 590 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPermuteWorkloadValidate, reasonIfUnsupported, descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 591 | } |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 592 | |
| 593 | bool ClLayerSupport::IsPooling2dSupported(const TensorInfo& input, |
| 594 | const TensorInfo& output, |
| 595 | const Pooling2dDescriptor& descriptor, |
| 596 | Optional<std::string&> reasonIfUnsupported) const |
| 597 | { |
| 598 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPooling2dWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 599 | } |
| 600 | |
Nikhil Raj | 91e4c6d | 2019-07-05 12:22:58 +0100 | [diff] [blame] | 601 | bool ClLayerSupport::IsPreluSupported(const armnn::TensorInfo &input, |
| 602 | const armnn::TensorInfo &alpha, |
| 603 | const armnn::TensorInfo &output, |
| 604 | armnn::Optional<std::string &> reasonIfUnsupported) const |
| 605 | { |
| 606 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPreluWorkloadValidate, reasonIfUnsupported, input, alpha, output); |
| 607 | } |
| 608 | |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 609 | bool ClLayerSupport::IsQuantizedLstmSupported(const TensorInfo& input, |
| 610 | const TensorInfo& previousCellStateIn, |
| 611 | const TensorInfo& previousOutputIn, |
| 612 | const TensorInfo& cellStateOut, |
| 613 | const TensorInfo& output, |
| 614 | const QuantizedLstmInputParamsInfo& paramsInfo, |
| 615 | Optional<std::string&> reasonIfUnsupported) const |
| 616 | { |
| 617 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClQuantizedLstmWorkloadValidate, |
| 618 | reasonIfUnsupported, |
| 619 | input, |
| 620 | previousCellStateIn, |
| 621 | previousOutputIn, |
| 622 | cellStateOut, |
| 623 | output, |
| 624 | paramsInfo); |
| 625 | } |
| 626 | |
Sadik Armagan | 20ec249 | 2019-05-31 09:09:44 +0100 | [diff] [blame] | 627 | bool ClLayerSupport::IsQuantizeSupported(const TensorInfo& input, |
| 628 | const TensorInfo& output, |
| 629 | Optional<std::string&> reasonIfUnsupported) const |
| 630 | { |
| 631 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClQuantizeWorkloadValidate, |
| 632 | reasonIfUnsupported, |
| 633 | input, |
| 634 | output); |
| 635 | } |
| 636 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 637 | bool ClLayerSupport::IsReshapeSupported(const TensorInfo& input, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 638 | const ReshapeDescriptor& descriptor, |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 639 | Optional<std::string&> reasonIfUnsupported) const |
| 640 | { |
| 641 | ignore_unused(input); |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 642 | ignore_unused(descriptor); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 643 | ignore_unused(reasonIfUnsupported); |
| 644 | return true; |
| 645 | } |
| 646 | |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 647 | bool ClLayerSupport::IsResizeSupported(const TensorInfo& input, |
| 648 | const TensorInfo& output, |
| 649 | const ResizeDescriptor& descriptor, |
| 650 | Optional<std::string&> reasonIfUnsupported) const |
| 651 | { |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 652 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClResizeWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 653 | } |
| 654 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 655 | bool ClLayerSupport::IsResizeBilinearSupported(const TensorInfo& input, |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame] | 656 | const TensorInfo& output, |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 657 | Optional<std::string&> reasonIfUnsupported) const |
| 658 | { |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 659 | ResizeDescriptor descriptor; |
| 660 | descriptor.m_Method = ResizeMethod::Bilinear; |
| 661 | descriptor.m_DataLayout = DataLayout::NCHW; |
| 662 | |
| 663 | const TensorShape& outputShape = output.GetShape(); |
| 664 | descriptor.m_TargetHeight = outputShape[2]; |
| 665 | descriptor.m_TargetWidth = outputShape[3]; |
| 666 | |
| 667 | return IsResizeSupported(input, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 668 | } |
| 669 | |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 670 | bool ClLayerSupport::IsRsqrtSupported(const TensorInfo& input, |
| 671 | const TensorInfo& output, |
| 672 | Optional<std::string&> reasonIfUnsupported) const |
| 673 | { |
| 674 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClRsqrtWorkloadValidate, reasonIfUnsupported, input, output); |
| 675 | } |
| 676 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 677 | bool ClLayerSupport::IsSoftmaxSupported(const TensorInfo& input, |
| 678 | const TensorInfo& output, |
| 679 | const SoftmaxDescriptor& descriptor, |
| 680 | Optional<std::string&> reasonIfUnsupported) const |
| 681 | { |
Francis Murtagh | 3b93835 | 2019-07-26 15:44:17 +0100 | [diff] [blame] | 682 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSoftmaxWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 683 | } |
| 684 | |
Sadik Armagan | f446432 | 2018-12-20 16:19:12 +0000 | [diff] [blame] | 685 | bool ClLayerSupport::IsSpaceToBatchNdSupported(const TensorInfo& input, |
| 686 | const TensorInfo& output, |
| 687 | const SpaceToBatchNdDescriptor& descriptor, |
| 688 | Optional<std::string&> reasonIfUnsupported) const |
| 689 | { |
| 690 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSpaceToBatchNdWorkloadValidate, |
| 691 | reasonIfUnsupported, |
| 692 | input, |
| 693 | output, |
| 694 | descriptor); |
| 695 | } |
| 696 | |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 697 | bool ClLayerSupport::IsSpaceToDepthSupported(const TensorInfo& input, |
| 698 | const TensorInfo& output, |
| 699 | const SpaceToDepthDescriptor& descriptor, |
| 700 | Optional<std::string&> reasonIfUnsupported) const |
| 701 | { |
| 702 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSpaceToDepthWorkloadValidate, |
| 703 | reasonIfUnsupported, |
| 704 | input, |
| 705 | output, |
| 706 | descriptor); |
| 707 | } |
| 708 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 709 | bool ClLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 710 | const ViewsDescriptor& descriptor, |
| 711 | Optional<std::string&> reasonIfUnsupported) const |
| 712 | { |
| 713 | ignore_unused(descriptor); |
| 714 | return IsSupportedForDataTypeCl(reasonIfUnsupported, |
| 715 | input.GetDataType(), |
| 716 | &TrueFunc<>, |
| 717 | &TrueFunc<>); |
| 718 | } |
| 719 | |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 720 | bool ClLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 721 | const std::vector<std::reference_wrapper<TensorInfo>>& outputs, |
| 722 | const ViewsDescriptor& descriptor, |
| 723 | Optional<std::string&> reasonIfUnsupported) const |
| 724 | { |
Narumol Prangnawarat | 7413583 | 2019-05-23 15:07:33 +0100 | [diff] [blame] | 725 | #if defined(ARMCOMPUTECL_ENABLED) |
| 726 | // Split along the last dimension, cannot use sub-tensors |
| 727 | // as width and height of the sub-tensors do not match |
| 728 | // the width and height of the parent tensor |
| 729 | // in case of input with more than 2D. |
| 730 | std::set<unsigned int> splitAxis = ComputeSplitAxis(descriptor, input.GetShape()); |
| 731 | if (descriptor.GetNumDimensions() > 2 && splitAxis.size() == 1 && |
| 732 | *splitAxis.begin() == descriptor.GetNumDimensions() - 1 ) |
| 733 | { |
| 734 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSplitterWorkloadValidate, |
| 735 | reasonIfUnsupported, |
| 736 | input, |
| 737 | outputs, |
| 738 | *splitAxis.begin()); |
| 739 | } |
| 740 | #endif |
| 741 | for (auto output : outputs) |
| 742 | { |
| 743 | if (!input.IsTypeSpaceMatch(output)) // Cannot use sub-tensors if the types are not same space |
| 744 | { |
| 745 | SetValueChecked(reasonIfUnsupported, "Cl Splitter: Types and quantization parameters must match."); |
| 746 | return false; |
| 747 | } |
| 748 | } |
| 749 | return true; |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 750 | } |
| 751 | |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 752 | bool ClLayerSupport::IsStackSupported(const std::vector<const TensorInfo*>& inputs, |
| 753 | const TensorInfo& output, |
| 754 | const StackDescriptor& descriptor, |
| 755 | Optional<std::string&> reasonIfUnsupported) const |
| 756 | { |
| 757 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClStackWorkloadValidate, |
| 758 | reasonIfUnsupported, |
| 759 | inputs, |
| 760 | output, |
| 761 | descriptor); |
| 762 | } |
| 763 | |
keidav01 | d74dc91 | 2018-12-10 18:16:07 +0000 | [diff] [blame] | 764 | bool ClLayerSupport::IsStridedSliceSupported(const TensorInfo& input, |
| 765 | const TensorInfo& output, |
| 766 | const StridedSliceDescriptor& descriptor, |
| 767 | Optional<std::string&> reasonIfUnsupported) const |
| 768 | { |
| 769 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClStridedSliceWorkloadValidate, |
| 770 | reasonIfUnsupported, |
| 771 | input, |
| 772 | output, |
| 773 | descriptor); |
| 774 | } |
| 775 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 776 | bool ClLayerSupport::IsSubtractionSupported(const TensorInfo& input0, |
| 777 | const TensorInfo& input1, |
| 778 | const TensorInfo& output, |
| 779 | Optional<std::string&> reasonIfUnsupported) const |
| 780 | { |
| 781 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSubtractionValidate, |
| 782 | reasonIfUnsupported, |
| 783 | input0, |
| 784 | input1, |
| 785 | output); |
| 786 | } |
| 787 | |
Aron Virginas-Tar | 7a3e2fe | 2019-06-27 18:54:47 +0100 | [diff] [blame] | 788 | bool ClLayerSupport::IsTransposeConvolution2dSupported(const TensorInfo& input, |
| 789 | const TensorInfo& output, |
| 790 | const TransposeConvolution2dDescriptor& descriptor, |
| 791 | const TensorInfo& weights, |
| 792 | const Optional<TensorInfo>& biases, |
| 793 | Optional<std::string&> reasonIfUnsupported) const |
| 794 | { |
| 795 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClTransposeConvolution2dWorkloadValidate, |
| 796 | reasonIfUnsupported, |
| 797 | input, |
| 798 | output, |
| 799 | descriptor, |
| 800 | weights, |
| 801 | biases); |
| 802 | } |
| 803 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 804 | } // namespace armnn |