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