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