telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
Teresa Charlin | 8398edc | 2020-07-20 14:23:02 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. 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" |
Sadik Armagan | 045f6be | 2020-09-10 13:37:32 +0100 | [diff] [blame] | 8 | #include "ClBackendModelContext.hpp" |
arovir01 | 7c22c70 | 2018-10-09 11:16:46 +0100 | [diff] [blame] | 9 | |
David Beck | 3cc9a62 | 2018-10-12 10:38:31 +0100 | [diff] [blame] | 10 | #include <armnn/Descriptors.hpp> |
Matteo Martincigh | c601aa6 | 2019-10-29 15:03:22 +0000 | [diff] [blame] | 11 | #include <armnn/BackendRegistry.hpp> |
| 12 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 13 | #include <InternalTypes.hpp> |
| 14 | #include <LayerSupportCommon.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 15 | |
Sadik Armagan | 045f6be | 2020-09-10 13:37:32 +0100 | [diff] [blame] | 16 | #include <armnn/utility/IgnoreUnused.hpp> |
| 17 | #include <armnn/utility/PolymorphicDowncast.hpp> |
| 18 | |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 19 | #if defined(ARMCOMPUTECL_ENABLED) |
Narumol Prangnawarat | 7413583 | 2019-05-23 15:07:33 +0100 | [diff] [blame] | 20 | #include <aclCommon/ArmComputeUtils.hpp> |
Aron Virginas-Tar | 710f664 | 2019-11-27 14:48:32 +0000 | [diff] [blame] | 21 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
Aron Virginas-Tar | 8204694 | 2019-09-09 15:18:29 +0100 | [diff] [blame] | 22 | #include "workloads/ClAbsWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 23 | #include "workloads/ClAdditionWorkload.hpp" |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 24 | #include "workloads/ClActivationWorkload.hpp" |
James Conroy | 2dc0572 | 2019-09-19 17:00:31 +0100 | [diff] [blame] | 25 | #include "workloads/ClArgMinMaxWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 26 | #include "workloads/ClBatchNormalizationFloatWorkload.hpp" |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 27 | #include "workloads/ClBatchToSpaceNdWorkload.hpp" |
Sadik Armagan | f40d6d4 | 2021-04-22 09:12:11 +0100 | [diff] [blame] | 28 | #include "workloads/ClCastWorkload.hpp" |
Teresa Charlin | 2b030d9 | 2020-03-27 16:40:56 +0000 | [diff] [blame] | 29 | #include "workloads/ClComparisonWorkload.hpp" |
Mike Kelly | 0886ac4 | 2020-04-27 09:55:40 +0100 | [diff] [blame] | 30 | #include "workloads/ClConstantWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 31 | #include "workloads/ClConvertFp16ToFp32Workload.hpp" |
| 32 | #include "workloads/ClConvertFp32ToFp16Workload.hpp" |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 33 | #include "workloads/ClConvolution2dWorkload.hpp" |
Aron Virginas-Tar | b280196 | 2019-09-30 11:24:53 +0100 | [diff] [blame] | 34 | #include "workloads/ClDepthToSpaceWorkload.hpp" |
Matthew Bentham | d877739 | 2018-10-08 09:38:55 +0100 | [diff] [blame] | 35 | #include "workloads/ClDepthwiseConvolutionWorkload.hpp" |
Aron Virginas-Tar | b280196 | 2019-09-30 11:24:53 +0100 | [diff] [blame] | 36 | #include "workloads/ClDequantizeWorkload.hpp" |
Teresa Charlin | e11e63d | 2021-04-21 12:56:45 +0100 | [diff] [blame] | 37 | #include "workloads/ClDivisionWorkload.hpp" |
Sadik Armagan | 9fabf43 | 2020-05-27 13:40:58 +0100 | [diff] [blame] | 38 | #include "workloads/ClExpWorkload.hpp" |
Sadik Armagan | 66aecb0 | 2020-06-24 11:42:20 +0100 | [diff] [blame] | 39 | #include "workloads/ClFillWorkload.hpp" |
Sadik Armagan | 9be4916 | 2019-10-30 16:15:26 +0000 | [diff] [blame] | 40 | #include "workloads/ClFloorFloatWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 41 | #include "workloads/ClFullyConnectedWorkload.hpp" |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 42 | #include "workloads/ClGatherWorkload.hpp" |
Aron Virginas-Tar | 8168f40 | 2019-10-04 13:10:16 +0100 | [diff] [blame] | 43 | #include "workloads/ClInstanceNormalizationWorkload.hpp" |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 44 | #include "workloads/ClL2NormalizationFloatWorkload.hpp" |
Teresa Charlin | 50de4fa | 2021-05-31 18:47:33 +0100 | [diff] [blame] | 45 | #include "workloads/ClLogWorkload.hpp" |
Teresa Charlin | 8398edc | 2020-07-20 14:23:02 +0100 | [diff] [blame] | 46 | #include "workloads/ClLogSoftmaxWorkload.hpp" |
James Conroy | fe3ec94 | 2020-11-18 14:20:53 +0000 | [diff] [blame] | 47 | #include "workloads/ClLogicalAndWorkload.hpp" |
| 48 | #include "workloads/ClLogicalNotWorkload.hpp" |
| 49 | #include "workloads/ClLogicalOrWorkload.hpp" |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 50 | #include "workloads/ClLstmFloatWorkload.hpp" |
keidav01 | a959ee5 | 2018-12-19 10:04:58 +0000 | [diff] [blame] | 51 | #include "workloads/ClMaximumWorkload.hpp" |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 52 | #include "workloads/ClMeanWorkload.hpp" |
Jim Flynn | 6905941 | 2019-05-17 13:03:57 +0100 | [diff] [blame] | 53 | #include "workloads/ClConcatWorkload.hpp" |
saoste01 | 9292aa3 | 2019-01-08 13:55:59 +0000 | [diff] [blame] | 54 | #include "workloads/ClMinimumWorkload.hpp" |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 55 | #include "workloads/ClMultiplicationWorkload.hpp" |
Sadik Armagan | ac47210 | 2020-03-24 09:54:36 +0000 | [diff] [blame] | 56 | #include "workloads/ClNegWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 57 | #include "workloads/ClNormalizationFloatWorkload.hpp" |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 58 | #include "workloads/ClPadWorkload.hpp" |
| 59 | #include "workloads/ClPermuteWorkload.hpp" |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 60 | #include "workloads/ClPooling2dWorkload.hpp" |
Nikhil Raj | 91e4c6d | 2019-07-05 12:22:58 +0100 | [diff] [blame] | 61 | #include "workloads/ClPreluWorkload.hpp" |
Ryan OShea | 2323af4 | 2020-05-13 16:36:19 +0100 | [diff] [blame] | 62 | #include "workloads/ClQLstmWorkload.hpp" |
| 63 | #include "workloads/ClQuantizedLstmWorkload.hpp" |
| 64 | #include "workloads/ClQuantizeWorkload.hpp" |
Sadik Armagan | a274748 | 2021-02-09 10:28:54 +0000 | [diff] [blame] | 65 | #include "workloads/ClReduceWorkload.hpp" |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 66 | #include "workloads/ClReshapeWorkload.hpp" |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 67 | #include "workloads/ClResizeWorkload.hpp" |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 68 | #include "workloads/ClRsqrtWorkload.hpp" |
Teresa Charlin | 50de4fa | 2021-05-31 18:47:33 +0100 | [diff] [blame] | 69 | #include "workloads/ClSinWorkload.hpp" |
Aron Virginas-Tar | 94c4fef | 2019-11-25 15:37:08 +0000 | [diff] [blame] | 70 | #include "workloads/ClSliceWorkload.hpp" |
Teresa Charlin | c1f6b09 | 2020-05-11 16:10:38 +0100 | [diff] [blame] | 71 | #include "workloads/ClSoftmaxWorkload.hpp" |
Sadik Armagan | f446432 | 2018-12-20 16:19:12 +0000 | [diff] [blame] | 72 | #include "workloads/ClSpaceToBatchNdWorkload.hpp" |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 73 | #include "workloads/ClSpaceToDepthWorkload.hpp" |
Narumol Prangnawarat | 7413583 | 2019-05-23 15:07:33 +0100 | [diff] [blame] | 74 | #include "workloads/ClSplitterWorkload.hpp" |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 75 | #include "workloads/ClStackWorkload.hpp" |
keidav01 | d74dc91 | 2018-12-10 18:16:07 +0000 | [diff] [blame] | 76 | #include "workloads/ClStridedSliceWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 77 | #include "workloads/ClSubtractionWorkload.hpp" |
Aron Virginas-Tar | 7a3e2fe | 2019-06-27 18:54:47 +0100 | [diff] [blame] | 78 | #include "workloads/ClTransposeConvolution2dWorkload.hpp" |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 79 | #include "workloads/ClTransposeWorkload.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 80 | #endif |
| 81 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 82 | |
| 83 | namespace armnn |
| 84 | { |
arovir01 | 7c22c70 | 2018-10-09 11:16:46 +0100 | [diff] [blame] | 85 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 86 | namespace |
| 87 | { |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 88 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 89 | template<unsigned int FilterSize> |
| 90 | bool IsMatchingSize2d(const TensorInfo& weightInfo) |
| 91 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 92 | // Width & Height must match. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 93 | return (weightInfo.GetShape()[3] == FilterSize) && (weightInfo.GetShape()[2] == FilterSize); |
| 94 | } |
| 95 | |
| 96 | template<uint32_t ValidStride> |
| 97 | bool IsMatchingStride(uint32_t actualStride) |
| 98 | { |
| 99 | return ValidStride == actualStride; |
| 100 | } |
| 101 | |
| 102 | template<uint32_t FirstStride, uint32_t SecondStride, uint32_t... ValidStrides> |
| 103 | bool IsMatchingStride(uint32_t actualStride) |
| 104 | { |
| 105 | return IsMatchingStride<FirstStride>(actualStride) || IsMatchingStride<SecondStride, ValidStrides...>(actualStride); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 106 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 107 | |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 108 | template<typename ... Args> |
| 109 | bool IsClBackendSupported(Optional<std::string&> reasonIfUnsupported, Args... args) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 110 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 111 | IgnoreUnused(reasonIfUnsupported, (args)...); |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 112 | #if defined(ARMCOMPUTECL_ENABLED) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 113 | return true; |
| 114 | #else |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 115 | if (reasonIfUnsupported) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 116 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 117 | reasonIfUnsupported.value() = "The armnn library has been built without CL support"; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 118 | } |
| 119 | return false; |
| 120 | #endif |
| 121 | } |
| 122 | |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 123 | #if defined(ARMCOMPUTECL_ENABLED) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 124 | #define FORWARD_CL_LAYER_SUPPORT_FUNC(expr) (expr) |
| 125 | #else |
| 126 | #define FORWARD_CL_LAYER_SUPPORT_FUNC(expr) IsClBackendSupported(reasonIfUnsupported) |
| 127 | #endif |
| 128 | |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 129 | #if defined(ARMCOMPUTECL_ENABLED) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 130 | template<class FuncType, class... Args> |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 131 | inline bool IsWorkloadSupported(FuncType&& func, Optional<std::string&> reasonIfUnsupported, Args&&... args) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 132 | { |
| 133 | arm_compute::Status aclStatus = func(std::forward<Args>(args)...); |
| 134 | const bool supported = (aclStatus.error_code() == arm_compute::ErrorCode::OK); |
| 135 | if (!supported && reasonIfUnsupported) |
| 136 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 137 | reasonIfUnsupported.value() = aclStatus.error_description(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 138 | } |
| 139 | return supported; |
| 140 | } |
| 141 | |
| 142 | #define FORWARD_WORKLOAD_VALIDATE_FUNC(func, reasonIfUnsupported, ...) \ |
| 143 | return IsWorkloadSupported(func, reasonIfUnsupported, __VA_ARGS__); |
| 144 | #else |
| 145 | #define FORWARD_WORKLOAD_VALIDATE_FUNC(func, reasonIfUnsupported, ...) \ |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 146 | return IsClBackendSupported(reasonIfUnsupported, __VA_ARGS__); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 147 | #endif |
| 148 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 149 | template<typename FloatFunc, typename Uint8Func, typename ... Params> |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 150 | bool IsSupportedForDataTypeCl(Optional<std::string&> reasonIfUnsupported, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 151 | DataType dataType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 152 | FloatFunc floatFuncPtr, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 153 | Uint8Func uint8FuncPtr, |
| 154 | Params&&... params) |
| 155 | { |
| 156 | return IsClBackendSupported(reasonIfUnsupported) && |
| 157 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 158 | dataType, |
| 159 | floatFuncPtr, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 160 | floatFuncPtr, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 161 | uint8FuncPtr, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 162 | &FalseFunc<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 163 | &FalseFunc<>, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 164 | std::forward<Params>(params)...); |
| 165 | } |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 166 | } // anonymous namespace |
| 167 | |
Sadik Armagan | 045f6be | 2020-09-10 13:37:32 +0100 | [diff] [blame] | 168 | ClLayerSupport::ClLayerSupport(const IBackendInternal::IBackendSpecificModelContextPtr& modelContextPtr) |
| 169 | : m_ModelContextPtr(modelContextPtr) |
| 170 | { |
| 171 | } |
| 172 | |
| 173 | ClLayerSupport::ClLayerSupport() |
| 174 | : m_ModelContextPtr(nullptr) |
| 175 | { |
| 176 | } |
| 177 | |
Aron Virginas-Tar | 8204694 | 2019-09-09 15:18:29 +0100 | [diff] [blame] | 178 | bool ClLayerSupport::IsAbsSupported(const TensorInfo& input, |
| 179 | const TensorInfo& output, |
| 180 | Optional<std::string&> reasonIfUnsupported) const |
| 181 | { |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 182 | ElementwiseUnaryDescriptor descriptor(UnaryOperation::Abs); |
| 183 | return IsElementwiseUnarySupported(input, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | 8204694 | 2019-09-09 15:18:29 +0100 | [diff] [blame] | 184 | } |
| 185 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 186 | bool ClLayerSupport::IsActivationSupported(const TensorInfo& input, |
| 187 | const TensorInfo& output, |
| 188 | const ActivationDescriptor& descriptor, |
| 189 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 190 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 191 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClActivationWorkloadValidate, |
| 192 | reasonIfUnsupported, |
| 193 | input, |
| 194 | output, |
| 195 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 196 | } |
| 197 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 198 | bool ClLayerSupport::IsAdditionSupported(const TensorInfo& input0, |
| 199 | const TensorInfo& input1, |
| 200 | const TensorInfo& output, |
| 201 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 202 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 203 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClAdditionValidate, |
| 204 | reasonIfUnsupported, |
| 205 | input0, |
| 206 | input1, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 207 | output, |
| 208 | nullptr); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 209 | } |
| 210 | |
James Conroy | 2dc0572 | 2019-09-19 17:00:31 +0100 | [diff] [blame] | 211 | bool ClLayerSupport::IsArgMinMaxSupported(const TensorInfo& input, |
| 212 | const TensorInfo& output, |
| 213 | const ArgMinMaxDescriptor& descriptor, |
| 214 | Optional<std::string&> reasonIfUnsupported) const |
| 215 | { |
Francis Murtagh | 52ec346 | 2019-11-19 12:24:19 +0000 | [diff] [blame] | 216 | |
James Conroy | 2dc0572 | 2019-09-19 17:00:31 +0100 | [diff] [blame] | 217 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClArgMinMaxWorkloadValidate, |
| 218 | reasonIfUnsupported, |
| 219 | input, |
| 220 | output, |
| 221 | descriptor); |
| 222 | } |
| 223 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 224 | bool ClLayerSupport::IsBatchNormalizationSupported(const TensorInfo& input, |
| 225 | const TensorInfo& output, |
| 226 | const TensorInfo& mean, |
| 227 | const TensorInfo& var, |
| 228 | const TensorInfo& beta, |
| 229 | const TensorInfo& gamma, |
| 230 | const BatchNormalizationDescriptor& descriptor, |
| 231 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 232 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 233 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClBatchNormalizationValidate, |
| 234 | reasonIfUnsupported, |
| 235 | input, |
| 236 | output, |
| 237 | mean, |
| 238 | var, |
| 239 | beta, |
| 240 | gamma, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 241 | descriptor, |
| 242 | nullptr); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 243 | } |
| 244 | |
Sadik Armagan | f40d6d4 | 2021-04-22 09:12:11 +0100 | [diff] [blame] | 245 | bool ClLayerSupport::IsCastSupported(const TensorInfo& input, |
| 246 | const TensorInfo& output, |
| 247 | Optional<std::string&> reasonIfUnsupported) const |
| 248 | { |
| 249 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClCastValidate, |
| 250 | reasonIfUnsupported, |
| 251 | input, |
| 252 | output); |
| 253 | } |
| 254 | |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 255 | bool ClLayerSupport::IsBatchToSpaceNdSupported(const TensorInfo& input, |
| 256 | const TensorInfo& output, |
| 257 | const BatchToSpaceNdDescriptor& descriptor, |
| 258 | Optional<std::string&> reasonIfUnsupported) const |
| 259 | { |
| 260 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClBatchToSpaceNdWorkloadValidate, |
| 261 | reasonIfUnsupported, |
| 262 | input, |
| 263 | output, |
| 264 | descriptor); |
| 265 | } |
| 266 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 267 | bool ClLayerSupport::IsComparisonSupported(const TensorInfo& input0, |
| 268 | const TensorInfo& input1, |
| 269 | const TensorInfo& output, |
| 270 | const ComparisonDescriptor& descriptor, |
| 271 | Optional<std::string&> reasonIfUnsupported) const |
| 272 | { |
Teresa Charlin | 2b030d9 | 2020-03-27 16:40:56 +0000 | [diff] [blame] | 273 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClComparisonWorkloadValidate, |
| 274 | reasonIfUnsupported, |
| 275 | input0, |
| 276 | input1, |
| 277 | output, |
| 278 | descriptor); |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 279 | } |
| 280 | |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 281 | bool ClLayerSupport::IsConcatSupported(const std::vector<const TensorInfo*> inputs, |
| 282 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 283 | const ConcatDescriptor& descriptor, |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 284 | Optional<std::string&> reasonIfUnsupported) const |
| 285 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 286 | if (descriptor.GetNumDimensions() <= descriptor.GetConcatAxis()) |
| 287 | { |
| 288 | SetValueChecked(reasonIfUnsupported, "Cl Concat: Concat axis > Number of dimensions."); |
| 289 | return false; |
| 290 | } |
| 291 | |
| 292 | unsigned int concatInnerAxis = (descriptor.GetNumDimensions() - descriptor.GetConcatAxis()) - 1; |
| 293 | if(concatInnerAxis < 3) // Width, height, or channels |
| 294 | { |
| 295 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConcatWorkloadValidate, |
| 296 | reasonIfUnsupported, |
| 297 | inputs, |
| 298 | output, |
| 299 | descriptor); |
| 300 | } |
| 301 | else if (concatInnerAxis == 3) |
| 302 | { |
| 303 | // We rely on the sub-tensor optimization to handle the batch dimension for 4D tensors. If we can't use |
| 304 | // sub-tensors for this then we can't support it. Here is where we check that the sub-tensors will work. |
| 305 | for (auto& input : inputs) |
| 306 | { |
| 307 | if (input && !output.IsTypeSpaceMatch(*input)) // Cannot use sub-tensors if the types are not same space |
| 308 | { |
| 309 | SetValueChecked(reasonIfUnsupported, "Cl Concat: Types and quantization parameters must match."); |
| 310 | return false; |
| 311 | } |
| 312 | } |
| 313 | return true; // Sub-tensors support concat along batch |
| 314 | } |
| 315 | else // > 4 dimensions not supported. |
| 316 | { |
| 317 | SetValueChecked(reasonIfUnsupported, "Cl Concat: Maximum of 4 dimensions supported."); |
| 318 | return false; |
| 319 | } |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 320 | } |
| 321 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 322 | bool ClLayerSupport::IsConstantSupported(const TensorInfo& output, |
| 323 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 324 | { |
Mike Kelly | 0886ac4 | 2020-04-27 09:55:40 +0100 | [diff] [blame] | 325 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConstantWorkloadValidate, |
| 326 | reasonIfUnsupported, |
| 327 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 328 | } |
| 329 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 330 | bool ClLayerSupport::IsConvertFp16ToFp32Supported(const TensorInfo& input, |
| 331 | const TensorInfo& output, |
| 332 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 333 | { |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 334 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConvertFp16ToFp32WorkloadValidate, |
| 335 | reasonIfUnsupported, |
| 336 | input, |
| 337 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 338 | } |
| 339 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 340 | bool ClLayerSupport::IsConvertFp32ToFp16Supported(const TensorInfo& input, |
| 341 | const TensorInfo& output, |
| 342 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 343 | { |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 344 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConvertFp32ToFp16WorkloadValidate, |
| 345 | reasonIfUnsupported, |
| 346 | input, |
| 347 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 348 | } |
| 349 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 350 | bool ClLayerSupport::IsConvolution2dSupported(const TensorInfo& input, |
| 351 | const TensorInfo& output, |
| 352 | const Convolution2dDescriptor& descriptor, |
| 353 | const TensorInfo& weights, |
| 354 | const Optional<TensorInfo>& biases, |
| 355 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 356 | { |
Sadik Armagan | 045f6be | 2020-09-10 13:37:32 +0100 | [diff] [blame] | 357 | bool isFastMathEnabled = false; |
| 358 | #if defined(ARMCOMPUTECL_ENABLED) |
| 359 | if (m_ModelContextPtr) |
| 360 | { |
| 361 | if (m_ModelContextPtr.get() != nullptr) |
| 362 | { |
| 363 | auto modelOptions = dynamic_cast<ClBackendModelContext*>(m_ModelContextPtr.get()); |
| 364 | if (modelOptions) |
| 365 | { |
| 366 | isFastMathEnabled = modelOptions->IsFastMathEnabled(); |
| 367 | } |
| 368 | } |
| 369 | } |
| 370 | #endif |
| 371 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 372 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClConvolution2dWorkloadValidate, |
| 373 | reasonIfUnsupported, |
| 374 | input, |
| 375 | output, |
| 376 | descriptor, |
| 377 | weights, |
Sadik Armagan | 045f6be | 2020-09-10 13:37:32 +0100 | [diff] [blame] | 378 | biases, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 379 | isFastMathEnabled, |
| 380 | nullptr); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 381 | } |
| 382 | |
Jim Flynn | 983daec | 2019-05-29 16:20:16 +0100 | [diff] [blame] | 383 | bool ClLayerSupport::IsDequantizeSupported(const TensorInfo& input, |
| 384 | const TensorInfo& output, |
| 385 | Optional<std::string&> reasonIfUnsupported) const |
| 386 | { |
| 387 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDequantizeWorkloadValidate, |
| 388 | reasonIfUnsupported, |
| 389 | input, |
| 390 | output); |
| 391 | } |
| 392 | |
Aron Virginas-Tar | b280196 | 2019-09-30 11:24:53 +0100 | [diff] [blame] | 393 | bool ClLayerSupport::IsDepthToSpaceSupported(const TensorInfo& input, |
| 394 | const TensorInfo& output, |
| 395 | const DepthToSpaceDescriptor& descriptor, |
| 396 | Optional<std::string&> reasonIfUnsupported) const |
| 397 | { |
| 398 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDepthToSpaceWorkloadValidate, |
| 399 | reasonIfUnsupported, |
| 400 | input, |
| 401 | output, |
| 402 | descriptor); |
| 403 | } |
| 404 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 405 | bool ClLayerSupport::IsDepthwiseConvolutionSupported(const TensorInfo& input, |
| 406 | const TensorInfo& output, |
| 407 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 408 | const TensorInfo& weights, |
| 409 | const Optional<TensorInfo>& biases, |
| 410 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 411 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 412 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDepthwiseConvolutionWorkloadValidate, |
| 413 | reasonIfUnsupported, |
| 414 | input, |
| 415 | output, |
| 416 | descriptor, |
| 417 | weights, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 418 | biases, |
| 419 | nullptr); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 420 | } |
| 421 | |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 422 | bool ClLayerSupport::IsDilatedDepthwiseConvolutionSupported(const TensorInfo& input, |
| 423 | const TensorInfo& output, |
| 424 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 425 | const TensorInfo& weights, |
| 426 | const Optional<TensorInfo>& biases, |
| 427 | Optional<std::string&> reasonIfUnsupported) const |
| 428 | { |
| 429 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDepthwiseConvolutionWorkloadValidate, |
| 430 | reasonIfUnsupported, |
| 431 | input, |
| 432 | output, |
| 433 | descriptor, |
| 434 | weights, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 435 | biases, |
| 436 | nullptr); |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 440 | bool ClLayerSupport::IsDivisionSupported(const TensorInfo& input0, |
| 441 | const TensorInfo& input1, |
| 442 | const TensorInfo& output, |
| 443 | Optional<std::string&> reasonIfUnsupported) const |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 444 | { |
| 445 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClDivisionWorkloadValidate, |
| 446 | reasonIfUnsupported, |
| 447 | input0, |
| 448 | input1, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 449 | output, |
| 450 | nullptr); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 451 | } |
| 452 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 453 | bool ClLayerSupport::IsElementwiseUnarySupported(const TensorInfo& input, |
| 454 | const TensorInfo& output, |
| 455 | const ElementwiseUnaryDescriptor& descriptor, |
| 456 | Optional<std::string&> reasonIfUnsupported) const |
| 457 | { |
Sadik Armagan | 9fabf43 | 2020-05-27 13:40:58 +0100 | [diff] [blame] | 458 | switch(descriptor.m_Operation) |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 459 | { |
Sadik Armagan | 9fabf43 | 2020-05-27 13:40:58 +0100 | [diff] [blame] | 460 | case UnaryOperation::Abs: |
| 461 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClAbsWorkloadValidate, |
| 462 | reasonIfUnsupported, |
| 463 | input, |
| 464 | output); |
| 465 | case UnaryOperation::Exp: |
| 466 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClExpWorkloadValidate, |
| 467 | reasonIfUnsupported, |
| 468 | input, |
| 469 | output); |
Teresa Charlin | 50de4fa | 2021-05-31 18:47:33 +0100 | [diff] [blame] | 470 | case UnaryOperation::Log: |
| 471 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClLogWorkloadValidate, |
| 472 | reasonIfUnsupported, |
| 473 | input, |
| 474 | output); |
| 475 | case UnaryOperation::LogicalNot: |
| 476 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClLogicalNotWorkloadValidate, |
| 477 | reasonIfUnsupported, |
| 478 | input, |
| 479 | output); |
Sadik Armagan | 9fabf43 | 2020-05-27 13:40:58 +0100 | [diff] [blame] | 480 | case UnaryOperation::Neg: |
| 481 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClNegWorkloadValidate, |
| 482 | reasonIfUnsupported, |
| 483 | input, |
| 484 | output); |
| 485 | case UnaryOperation::Rsqrt: |
| 486 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClRsqrtWorkloadValidate, |
| 487 | reasonIfUnsupported, |
| 488 | input, |
| 489 | output); |
Teresa Charlin | 50de4fa | 2021-05-31 18:47:33 +0100 | [diff] [blame] | 490 | case UnaryOperation::Sin: |
| 491 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSinWorkloadValidate, |
James Conroy | fe3ec94 | 2020-11-18 14:20:53 +0000 | [diff] [blame] | 492 | reasonIfUnsupported, |
| 493 | input, |
| 494 | output); |
Sadik Armagan | 9fabf43 | 2020-05-27 13:40:58 +0100 | [diff] [blame] | 495 | default: |
| 496 | return false; |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 497 | } |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 498 | } |
| 499 | |
Teresa Charlin | 4b10fef | 2020-07-29 09:36:41 +0100 | [diff] [blame] | 500 | bool ClLayerSupport::IsFillSupported(const TensorInfo& input, |
| 501 | const TensorInfo& output, |
| 502 | const FillDescriptor& descriptor, |
| 503 | Optional<std::string&> reasonIfUnsupported) const |
Sadik Armagan | 66aecb0 | 2020-06-24 11:42:20 +0100 | [diff] [blame] | 504 | { |
Teresa Charlin | 4b10fef | 2020-07-29 09:36:41 +0100 | [diff] [blame] | 505 | armnn::IgnoreUnused(input); |
| 506 | armnn::IgnoreUnused(output); |
| 507 | armnn::IgnoreUnused(descriptor); |
| 508 | |
| 509 | return IsClBackendSupported(reasonIfUnsupported); |
Sadik Armagan | 66aecb0 | 2020-06-24 11:42:20 +0100 | [diff] [blame] | 510 | } |
| 511 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 512 | bool ClLayerSupport::IsFloorSupported(const TensorInfo& input, |
| 513 | const TensorInfo& output, |
| 514 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 515 | { |
Sadik Armagan | 9be4916 | 2019-10-30 16:15:26 +0000 | [diff] [blame] | 516 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClFloorWorkloadValidate, |
| 517 | reasonIfUnsupported, |
| 518 | input, |
| 519 | output); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 520 | } |
| 521 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 522 | bool ClLayerSupport::IsFullyConnectedSupported(const TensorInfo& input, |
| 523 | const TensorInfo& output, |
| 524 | const TensorInfo& weights, |
| 525 | const TensorInfo& biases, |
| 526 | const FullyConnectedDescriptor& descriptor, |
| 527 | Optional<std::string&> reasonIfUnsupported) const |
| 528 | { |
| 529 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClFullyConnectedWorkloadValidate, |
| 530 | reasonIfUnsupported, |
| 531 | input, |
| 532 | output, |
| 533 | weights, |
| 534 | biases, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 535 | descriptor, |
| 536 | nullptr); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 537 | } |
| 538 | |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 539 | bool ClLayerSupport::IsGatherSupported(const TensorInfo& input0, |
| 540 | const TensorInfo& input1, |
| 541 | const TensorInfo& output, |
Teresa Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 542 | const GatherDescriptor& descriptor, |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 543 | Optional<std::string&> reasonIfUnsupported) const |
| 544 | { |
| 545 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClGatherWorkloadValidate, |
| 546 | reasonIfUnsupported, |
| 547 | input0, |
| 548 | input1, |
Teresa Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 549 | output, |
| 550 | descriptor); |
Teresa Charlin | 9ad2e5b | 2020-04-10 22:34:48 +0100 | [diff] [blame] | 551 | } |
| 552 | |
Nattapat Chaimanowong | c6a41ff | 2019-01-29 09:56:02 +0000 | [diff] [blame] | 553 | bool ClLayerSupport::IsGreaterSupported(const TensorInfo& input0, |
| 554 | const TensorInfo& input1, |
| 555 | const TensorInfo& output, |
| 556 | Optional<std::string&> reasonIfUnsupported) const |
| 557 | { |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 558 | ComparisonDescriptor descriptor(ComparisonOperation::Greater); |
| 559 | return IsComparisonSupported(input0, input1, output, descriptor, reasonIfUnsupported); |
Nattapat Chaimanowong | c6a41ff | 2019-01-29 09:56:02 +0000 | [diff] [blame] | 560 | } |
| 561 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 562 | bool ClLayerSupport::IsInputSupported(const TensorInfo& input, |
| 563 | Optional<std::string&> reasonIfUnsupported) const |
| 564 | { |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 565 | return IsClBackendSupported(reasonIfUnsupported, input); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 566 | } |
| 567 | |
Aron Virginas-Tar | 8168f40 | 2019-10-04 13:10:16 +0100 | [diff] [blame] | 568 | bool ClLayerSupport::IsInstanceNormalizationSupported(const TensorInfo& input, |
| 569 | const TensorInfo& output, |
| 570 | const InstanceNormalizationDescriptor& descriptor, |
| 571 | Optional<std::string&> reasonIfUnsupported) const |
| 572 | { |
| 573 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClInstanceNormalizationWorkloadValidate, |
| 574 | reasonIfUnsupported, |
| 575 | input, |
| 576 | output, |
| 577 | descriptor); |
| 578 | } |
| 579 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 580 | bool ClLayerSupport::IsL2NormalizationSupported(const TensorInfo& input, |
| 581 | const TensorInfo& output, |
| 582 | const L2NormalizationDescriptor& descriptor, |
| 583 | Optional<std::string&> reasonIfUnsupported) const |
| 584 | { |
| 585 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClL2NormalizationWorkloadValidate, |
| 586 | reasonIfUnsupported, |
| 587 | input, |
| 588 | output, |
| 589 | descriptor); |
| 590 | } |
| 591 | |
James Conroy | fe3ec94 | 2020-11-18 14:20:53 +0000 | [diff] [blame] | 592 | bool ClLayerSupport::IsLogicalBinarySupported(const TensorInfo& input0, |
| 593 | const TensorInfo& input1, |
| 594 | const TensorInfo& output, |
| 595 | const LogicalBinaryDescriptor& descriptor, |
| 596 | Optional<std::string&> reasonIfUnsupported) const |
| 597 | { |
| 598 | IgnoreUnused(output); |
| 599 | |
| 600 | switch(descriptor.m_Operation) |
| 601 | { |
| 602 | case LogicalBinaryOperation::LogicalAnd: |
| 603 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClLogicalAndWorkloadValidate, |
| 604 | reasonIfUnsupported, |
| 605 | input0, |
| 606 | input1, |
| 607 | output); |
| 608 | case LogicalBinaryOperation::LogicalOr: |
| 609 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClLogicalOrWorkloadValidate, |
| 610 | reasonIfUnsupported, |
| 611 | input0, |
| 612 | input1, |
| 613 | output); |
| 614 | default: |
| 615 | return false; |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | |
Teresa Charlin | 8398edc | 2020-07-20 14:23:02 +0100 | [diff] [blame] | 620 | bool ClLayerSupport::IsLogSoftmaxSupported(const TensorInfo& input, |
| 621 | const TensorInfo& output, |
| 622 | const LogSoftmaxDescriptor& descriptor, |
| 623 | Optional<std::string&> reasonIfUnsupported) const |
| 624 | { |
| 625 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClLogSoftmaxWorkloadValidate, |
| 626 | reasonIfUnsupported, |
| 627 | input, |
| 628 | output, |
| 629 | descriptor); |
| 630 | } |
| 631 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 632 | bool ClLayerSupport::IsLstmSupported(const TensorInfo& input, |
| 633 | const TensorInfo& outputStateIn, |
| 634 | const TensorInfo& cellStateIn, |
| 635 | const TensorInfo& scratchBuffer, |
| 636 | const TensorInfo& outputStateOut, |
| 637 | const TensorInfo& cellStateOut, |
| 638 | const TensorInfo& output, |
| 639 | const LstmDescriptor& descriptor, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 640 | const LstmInputParamsInfo& paramsInfo, |
| 641 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 642 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 643 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClLstmFloatWorkloadValidate, |
| 644 | reasonIfUnsupported, |
| 645 | input, |
| 646 | outputStateIn, |
| 647 | cellStateIn, |
| 648 | scratchBuffer, |
| 649 | outputStateOut, |
| 650 | cellStateOut, |
| 651 | output, |
| 652 | descriptor, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 653 | paramsInfo); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 654 | } |
| 655 | |
keidav01 | a959ee5 | 2018-12-19 10:04:58 +0000 | [diff] [blame] | 656 | bool ClLayerSupport::IsMaximumSupported(const TensorInfo& input0, |
| 657 | const TensorInfo& input1, |
| 658 | const TensorInfo& output, |
| 659 | Optional<std::string&> reasonIfUnsupported) const |
| 660 | { |
| 661 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMaximumWorkloadValidate, |
| 662 | reasonIfUnsupported, |
| 663 | input0, |
| 664 | input1, |
| 665 | output); |
| 666 | } |
| 667 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 668 | bool ClLayerSupport::IsMeanSupported(const TensorInfo& input, |
| 669 | const TensorInfo& output, |
| 670 | const MeanDescriptor& descriptor, |
| 671 | Optional<std::string&> reasonIfUnsupported) const |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 672 | { |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 673 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMeanValidate, |
| 674 | reasonIfUnsupported, |
| 675 | input, |
| 676 | output, |
| 677 | descriptor); |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 678 | } |
| 679 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 680 | bool ClLayerSupport::IsMergerSupported(const std::vector<const TensorInfo*> inputs, |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 681 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 682 | const MergerDescriptor& descriptor, |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 683 | Optional<std::string&> reasonIfUnsupported) const |
| 684 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 685 | return IsConcatSupported(inputs, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 686 | } |
| 687 | |
saoste01 | 9292aa3 | 2019-01-08 13:55:59 +0000 | [diff] [blame] | 688 | bool ClLayerSupport::IsMinimumSupported(const TensorInfo& input0, |
| 689 | const TensorInfo& input1, |
| 690 | const TensorInfo& output, |
| 691 | Optional<std::string&> reasonIfUnsupported) const |
| 692 | { |
| 693 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMinimumWorkloadValidate, |
| 694 | reasonIfUnsupported, |
| 695 | input0, |
| 696 | input1, |
| 697 | output); |
| 698 | } |
| 699 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 700 | bool ClLayerSupport::IsMultiplicationSupported(const TensorInfo& input0, |
| 701 | const TensorInfo& input1, |
| 702 | const TensorInfo& output, |
| 703 | Optional<std::string&> reasonIfUnsupported) const |
| 704 | { |
| 705 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClMultiplicationWorkloadValidate, |
| 706 | reasonIfUnsupported, |
| 707 | input0, |
| 708 | input1, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 709 | output, |
| 710 | nullptr); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | bool ClLayerSupport::IsNormalizationSupported(const TensorInfo& input, |
| 714 | const TensorInfo& output, |
| 715 | const NormalizationDescriptor& descriptor, |
| 716 | Optional<std::string&> reasonIfUnsupported) const |
| 717 | { |
| 718 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClNormalizationWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 719 | } |
| 720 | |
| 721 | bool ClLayerSupport::IsOutputSupported(const TensorInfo& output, |
| 722 | Optional<std::string&> reasonIfUnsupported) const |
| 723 | { |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 724 | return IsClBackendSupported(reasonIfUnsupported, output); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | bool ClLayerSupport::IsPadSupported(const TensorInfo& input, |
| 728 | const TensorInfo& output, |
| 729 | const PadDescriptor& descriptor, |
| 730 | Optional<std::string&> reasonIfUnsupported) const |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 731 | { |
| 732 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPadValidate, |
| 733 | reasonIfUnsupported, |
| 734 | input, |
| 735 | output, |
| 736 | descriptor); |
| 737 | } |
| 738 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 739 | bool ClLayerSupport::IsPermuteSupported(const TensorInfo& input, |
| 740 | const TensorInfo& output, |
| 741 | const PermuteDescriptor& descriptor, |
| 742 | Optional<std::string&> reasonIfUnsupported) const |
| 743 | { |
Matthew Bentham | 9820d30 | 2019-11-27 17:24:47 +0000 | [diff] [blame] | 744 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPermuteWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 745 | } |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 746 | |
| 747 | bool ClLayerSupport::IsPooling2dSupported(const TensorInfo& input, |
| 748 | const TensorInfo& output, |
| 749 | const Pooling2dDescriptor& descriptor, |
| 750 | Optional<std::string&> reasonIfUnsupported) const |
| 751 | { |
| 752 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPooling2dWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 753 | } |
| 754 | |
Nikhil Raj | 91e4c6d | 2019-07-05 12:22:58 +0100 | [diff] [blame] | 755 | bool ClLayerSupport::IsPreluSupported(const armnn::TensorInfo &input, |
| 756 | const armnn::TensorInfo &alpha, |
| 757 | const armnn::TensorInfo &output, |
| 758 | armnn::Optional<std::string &> reasonIfUnsupported) const |
| 759 | { |
| 760 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClPreluWorkloadValidate, reasonIfUnsupported, input, alpha, output); |
| 761 | } |
| 762 | |
Ryan OShea | 2323af4 | 2020-05-13 16:36:19 +0100 | [diff] [blame] | 763 | bool ClLayerSupport::IsQLstmSupported(const TensorInfo& input, |
| 764 | const TensorInfo& previousOutputIn, |
| 765 | const TensorInfo& previousCellStateIn, |
| 766 | const TensorInfo& outputStateOut, |
| 767 | const TensorInfo& cellStateOut, |
| 768 | const TensorInfo& output, |
| 769 | const QLstmDescriptor& descriptor, |
| 770 | const LstmInputParamsInfo& paramsInfo, |
| 771 | Optional<std::string&> reasonIfUnsupported) const |
| 772 | { |
| 773 | if (input.GetDataType() == armnn::DataType::QAsymmS8 && |
| 774 | previousOutputIn.GetDataType() == armnn::DataType::QAsymmS8 && |
| 775 | previousCellStateIn.GetDataType() == armnn::DataType::QSymmS16 && |
| 776 | outputStateOut.GetDataType() == armnn::DataType::QAsymmS8 && |
| 777 | cellStateOut.GetDataType() == armnn::DataType::QSymmS16 && |
| 778 | output.GetDataType() == armnn::DataType::QAsymmS8) |
| 779 | { |
| 780 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClQLstmWorkloadValidate, |
| 781 | reasonIfUnsupported, |
| 782 | input, |
| 783 | previousCellStateIn, |
| 784 | previousOutputIn, |
| 785 | cellStateOut, |
| 786 | outputStateOut, |
| 787 | output, |
| 788 | descriptor, |
| 789 | paramsInfo); |
| 790 | } |
| 791 | else |
| 792 | { |
| 793 | return false; |
| 794 | } |
| 795 | } |
| 796 | |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 797 | bool ClLayerSupport::IsQuantizedLstmSupported(const TensorInfo& input, |
| 798 | const TensorInfo& previousCellStateIn, |
| 799 | const TensorInfo& previousOutputIn, |
| 800 | const TensorInfo& cellStateOut, |
| 801 | const TensorInfo& output, |
| 802 | const QuantizedLstmInputParamsInfo& paramsInfo, |
| 803 | Optional<std::string&> reasonIfUnsupported) const |
| 804 | { |
| 805 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClQuantizedLstmWorkloadValidate, |
| 806 | reasonIfUnsupported, |
| 807 | input, |
| 808 | previousCellStateIn, |
| 809 | previousOutputIn, |
| 810 | cellStateOut, |
| 811 | output, |
| 812 | paramsInfo); |
| 813 | } |
| 814 | |
Sadik Armagan | 20ec249 | 2019-05-31 09:09:44 +0100 | [diff] [blame] | 815 | bool ClLayerSupport::IsQuantizeSupported(const TensorInfo& input, |
| 816 | const TensorInfo& output, |
| 817 | Optional<std::string&> reasonIfUnsupported) const |
| 818 | { |
| 819 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClQuantizeWorkloadValidate, |
| 820 | reasonIfUnsupported, |
| 821 | input, |
| 822 | output); |
| 823 | } |
| 824 | |
Sadik Armagan | a274748 | 2021-02-09 10:28:54 +0000 | [diff] [blame] | 825 | bool ClLayerSupport::IsReduceSupported(const TensorInfo& input, |
| 826 | const TensorInfo& output, |
| 827 | const ReduceDescriptor& descriptor, |
| 828 | Optional<std::string&> reasonIfUnsupported) const |
| 829 | { |
| 830 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClReduceWorkloadValidate, |
| 831 | reasonIfUnsupported, |
| 832 | input, |
| 833 | output, |
| 834 | descriptor); |
| 835 | } |
| 836 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 837 | bool ClLayerSupport::IsReshapeSupported(const TensorInfo& input, |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 838 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 839 | const ReshapeDescriptor& descriptor, |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 840 | Optional<std::string&> reasonIfUnsupported) const |
| 841 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 842 | IgnoreUnused(descriptor); |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 843 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClReshapeWorkloadValidate, reasonIfUnsupported, input, output); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 844 | } |
| 845 | |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 846 | bool ClLayerSupport::IsResizeSupported(const TensorInfo& input, |
| 847 | const TensorInfo& output, |
| 848 | const ResizeDescriptor& descriptor, |
| 849 | Optional<std::string&> reasonIfUnsupported) const |
| 850 | { |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 851 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClResizeWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 852 | } |
| 853 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 854 | bool ClLayerSupport::IsResizeBilinearSupported(const TensorInfo& input, |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame] | 855 | const TensorInfo& output, |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 856 | Optional<std::string&> reasonIfUnsupported) const |
| 857 | { |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 858 | ResizeDescriptor descriptor; |
| 859 | descriptor.m_Method = ResizeMethod::Bilinear; |
| 860 | descriptor.m_DataLayout = DataLayout::NCHW; |
| 861 | |
| 862 | const TensorShape& outputShape = output.GetShape(); |
| 863 | descriptor.m_TargetHeight = outputShape[2]; |
| 864 | descriptor.m_TargetWidth = outputShape[3]; |
| 865 | |
| 866 | return IsResizeSupported(input, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 867 | } |
| 868 | |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 869 | bool ClLayerSupport::IsRsqrtSupported(const TensorInfo& input, |
| 870 | const TensorInfo& output, |
| 871 | Optional<std::string&> reasonIfUnsupported) const |
| 872 | { |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 873 | ElementwiseUnaryDescriptor descriptor(UnaryOperation::Rsqrt); |
| 874 | return IsElementwiseUnarySupported(input, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 875 | } |
| 876 | |
Aron Virginas-Tar | 94c4fef | 2019-11-25 15:37:08 +0000 | [diff] [blame] | 877 | bool ClLayerSupport::IsSliceSupported(const TensorInfo& input, |
| 878 | const TensorInfo& output, |
| 879 | const SliceDescriptor& descriptor, |
| 880 | Optional<std::string&> reasonIfUnsupported) const |
| 881 | { |
| 882 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSliceWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 883 | } |
| 884 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 885 | bool ClLayerSupport::IsSoftmaxSupported(const TensorInfo& input, |
| 886 | const TensorInfo& output, |
| 887 | const SoftmaxDescriptor& descriptor, |
| 888 | Optional<std::string&> reasonIfUnsupported) const |
| 889 | { |
Francis Murtagh | 3b93835 | 2019-07-26 15:44:17 +0100 | [diff] [blame] | 890 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSoftmaxWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 891 | } |
| 892 | |
Sadik Armagan | f446432 | 2018-12-20 16:19:12 +0000 | [diff] [blame] | 893 | bool ClLayerSupport::IsSpaceToBatchNdSupported(const TensorInfo& input, |
| 894 | const TensorInfo& output, |
| 895 | const SpaceToBatchNdDescriptor& descriptor, |
| 896 | Optional<std::string&> reasonIfUnsupported) const |
| 897 | { |
| 898 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSpaceToBatchNdWorkloadValidate, |
| 899 | reasonIfUnsupported, |
| 900 | input, |
| 901 | output, |
| 902 | descriptor); |
| 903 | } |
| 904 | |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 905 | bool ClLayerSupport::IsSpaceToDepthSupported(const TensorInfo& input, |
| 906 | const TensorInfo& output, |
| 907 | const SpaceToDepthDescriptor& descriptor, |
| 908 | Optional<std::string&> reasonIfUnsupported) const |
| 909 | { |
| 910 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSpaceToDepthWorkloadValidate, |
| 911 | reasonIfUnsupported, |
| 912 | input, |
| 913 | output, |
| 914 | descriptor); |
| 915 | } |
| 916 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 917 | bool ClLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 918 | const ViewsDescriptor& descriptor, |
| 919 | Optional<std::string&> reasonIfUnsupported) const |
| 920 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 921 | IgnoreUnused(descriptor); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 922 | return IsSupportedForDataTypeCl(reasonIfUnsupported, |
| 923 | input.GetDataType(), |
| 924 | &TrueFunc<>, |
| 925 | &TrueFunc<>); |
| 926 | } |
| 927 | |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 928 | bool ClLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 929 | const std::vector<std::reference_wrapper<TensorInfo>>& outputs, |
| 930 | const ViewsDescriptor& descriptor, |
| 931 | Optional<std::string&> reasonIfUnsupported) const |
| 932 | { |
Narumol Prangnawarat | 7413583 | 2019-05-23 15:07:33 +0100 | [diff] [blame] | 933 | #if defined(ARMCOMPUTECL_ENABLED) |
| 934 | // Split along the last dimension, cannot use sub-tensors |
| 935 | // as width and height of the sub-tensors do not match |
| 936 | // the width and height of the parent tensor |
| 937 | // in case of input with more than 2D. |
| 938 | std::set<unsigned int> splitAxis = ComputeSplitAxis(descriptor, input.GetShape()); |
| 939 | if (descriptor.GetNumDimensions() > 2 && splitAxis.size() == 1 && |
| 940 | *splitAxis.begin() == descriptor.GetNumDimensions() - 1 ) |
| 941 | { |
| 942 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSplitterWorkloadValidate, |
| 943 | reasonIfUnsupported, |
| 944 | input, |
| 945 | outputs, |
| 946 | *splitAxis.begin()); |
| 947 | } |
| 948 | #endif |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 949 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | 7413583 | 2019-05-23 15:07:33 +0100 | [diff] [blame] | 950 | for (auto output : outputs) |
| 951 | { |
| 952 | if (!input.IsTypeSpaceMatch(output)) // Cannot use sub-tensors if the types are not same space |
| 953 | { |
| 954 | SetValueChecked(reasonIfUnsupported, "Cl Splitter: Types and quantization parameters must match."); |
| 955 | return false; |
| 956 | } |
| 957 | } |
| 958 | return true; |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 959 | } |
| 960 | |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 961 | bool ClLayerSupport::IsStackSupported(const std::vector<const TensorInfo*>& inputs, |
| 962 | const TensorInfo& output, |
| 963 | const StackDescriptor& descriptor, |
| 964 | Optional<std::string&> reasonIfUnsupported) const |
| 965 | { |
| 966 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClStackWorkloadValidate, |
| 967 | reasonIfUnsupported, |
| 968 | inputs, |
| 969 | output, |
| 970 | descriptor); |
| 971 | } |
| 972 | |
keidav01 | d74dc91 | 2018-12-10 18:16:07 +0000 | [diff] [blame] | 973 | bool ClLayerSupport::IsStridedSliceSupported(const TensorInfo& input, |
| 974 | const TensorInfo& output, |
| 975 | const StridedSliceDescriptor& descriptor, |
| 976 | Optional<std::string&> reasonIfUnsupported) const |
| 977 | { |
| 978 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClStridedSliceWorkloadValidate, |
| 979 | reasonIfUnsupported, |
| 980 | input, |
| 981 | output, |
| 982 | descriptor); |
| 983 | } |
| 984 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 985 | bool ClLayerSupport::IsSubtractionSupported(const TensorInfo& input0, |
| 986 | const TensorInfo& input1, |
| 987 | const TensorInfo& output, |
| 988 | Optional<std::string&> reasonIfUnsupported) const |
| 989 | { |
| 990 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClSubtractionValidate, |
| 991 | reasonIfUnsupported, |
| 992 | input0, |
| 993 | input1, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 994 | output, |
| 995 | nullptr); |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 996 | } |
| 997 | |
Aron Virginas-Tar | 7a3e2fe | 2019-06-27 18:54:47 +0100 | [diff] [blame] | 998 | bool ClLayerSupport::IsTransposeConvolution2dSupported(const TensorInfo& input, |
| 999 | const TensorInfo& output, |
| 1000 | const TransposeConvolution2dDescriptor& descriptor, |
| 1001 | const TensorInfo& weights, |
| 1002 | const Optional<TensorInfo>& biases, |
| 1003 | Optional<std::string&> reasonIfUnsupported) const |
| 1004 | { |
| 1005 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClTransposeConvolution2dWorkloadValidate, |
| 1006 | reasonIfUnsupported, |
| 1007 | input, |
| 1008 | output, |
| 1009 | descriptor, |
| 1010 | weights, |
| 1011 | biases); |
| 1012 | } |
| 1013 | |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 1014 | bool ClLayerSupport::IsTransposeSupported(const TensorInfo& input, |
| 1015 | const TensorInfo& output, |
| 1016 | const TransposeDescriptor& descriptor, |
| 1017 | Optional<std::string&> reasonIfUnsupported) const |
| 1018 | { |
| 1019 | FORWARD_WORKLOAD_VALIDATE_FUNC(ClTransposeWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 1020 | } |
| 1021 | |
Aron Virginas-Tar | bcf9f16 | 2018-10-15 11:47:37 +0100 | [diff] [blame] | 1022 | } // namespace armnn |