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