telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | |
| 6 | #include "NeonLayerSupport.hpp" |
David Beck | 3e9e115 | 2018-10-17 14:17:50 +0100 | [diff] [blame] | 7 | #include "NeonBackendId.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 9 | #include <armnn/Descriptors.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 10 | #include <InternalTypes.hpp> |
| 11 | #include <LayerSupportCommon.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 12 | #include <armnn/Tensor.hpp> |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 13 | #include <armnn/Types.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 14 | |
David Beck | 111b5d9 | 2018-11-12 14:59:37 +0000 | [diff] [blame] | 15 | #include <backendsCommon/BackendRegistry.hpp> |
David Beck | 3e9e115 | 2018-10-17 14:17:50 +0100 | [diff] [blame] | 16 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 17 | #include <boost/core/ignore_unused.hpp> |
| 18 | |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 19 | #if defined(ARMCOMPUTENEON_ENABLED) |
Matthew Bentham | 955258d | 2018-12-10 10:48:52 +0000 | [diff] [blame] | 20 | #include "workloads/NeonAdditionWorkload.hpp" |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 21 | #include "workloads/NeonActivationWorkload.hpp" |
Matthew Bentham | c48ac8c | 2018-12-12 16:15:59 +0000 | [diff] [blame] | 22 | #include "workloads/NeonBatchNormalizationWorkload.hpp" |
Nattapat Chaimanowong | 974b65f | 2018-10-15 15:07:34 +0100 | [diff] [blame] | 23 | #include "workloads/NeonConvolution2dWorkload.hpp" |
Nattapat Chaimanowong | 7714088 | 2018-10-17 11:12:19 +0100 | [diff] [blame] | 24 | #include "workloads/NeonDepthwiseConvolutionWorkload.hpp" |
kevmay01 | eed8592 | 2019-01-28 08:37:25 +0000 | [diff] [blame] | 25 | #include "workloads/NeonGreaterWorkload.hpp" |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 26 | #include "workloads/NeonL2NormalizationFloatWorkload.hpp" |
Nattapat Chaimanowong | 4e6597a | 2018-12-20 14:14:06 +0000 | [diff] [blame] | 27 | #include "workloads/NeonMaximumWorkload.hpp" |
Matthew Bentham | fd89996 | 2018-12-31 15:49:42 +0000 | [diff] [blame] | 28 | #include "workloads/NeonMeanWorkload.hpp" |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 29 | #include "workloads/NeonMergerWorkload.hpp" |
Conor Kennedy | 54b2169 | 2019-01-09 07:57:38 +0000 | [diff] [blame] | 30 | #include "workloads/NeonMinimumWorkload.hpp" |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 31 | #include "workloads/NeonMultiplicationWorkload.hpp" |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 32 | #include "workloads/NeonNormalizationFloatWorkload.hpp" |
| 33 | #include "workloads/NeonFullyConnectedWorkload.hpp" |
Éanna Ó Catháin | 1205574 | 2019-01-25 10:01:40 +0000 | [diff] [blame] | 34 | #include "workloads/NeonPadWorkload.hpp" |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 35 | #include "workloads/NeonPermuteWorkload.hpp" |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 36 | #include "workloads/NeonPooling2dWorkload.hpp" |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame] | 37 | #include "workloads/NeonResizeBilinearWorkload.hpp" |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 38 | #include "workloads/NeonSoftmaxBaseWorkload.hpp" |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 39 | #include "workloads/NeonSubtractionWorkload.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 40 | #endif |
| 41 | |
| 42 | using namespace boost; |
| 43 | |
| 44 | namespace armnn |
| 45 | { |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 46 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 47 | namespace |
arovir01 | 7ff76c5 | 2018-10-09 09:40:58 +0100 | [diff] [blame] | 48 | { |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 49 | |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 50 | bool IsNeonBackendSupported(Optional<std::string&> reasonIfUnsupported) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 51 | { |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 52 | #if defined(ARMCOMPUTENEON_ENABLED) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 53 | return true; |
| 54 | #else |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 55 | if (reasonIfUnsupported) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 56 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 57 | reasonIfUnsupported.value() = "The armnn library has been built without NEON support"; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 58 | } |
| 59 | return false; |
| 60 | #endif |
| 61 | } |
| 62 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 63 | template<typename FloatFunc, typename Uint8Func, typename ... Params> |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 64 | bool IsSupportedForDataTypeNeon(Optional<std::string&> reasonIfUnsupported, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 65 | DataType dataType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 66 | FloatFunc floatFuncPtr, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 67 | Uint8Func uint8FuncPtr, |
| 68 | Params&&... params) |
| 69 | { |
| 70 | return IsNeonBackendSupported(reasonIfUnsupported) && |
| 71 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 72 | dataType, |
| 73 | floatFuncPtr, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 74 | floatFuncPtr, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 75 | uint8FuncPtr, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 76 | &FalseFunc<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 77 | &FalseFunc<>, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 78 | std::forward<Params>(params)...); |
| 79 | } |
| 80 | |
Matteo Martincigh | d95e906 | 2019-01-31 15:35:59 +0000 | [diff] [blame] | 81 | #if defined(ARMCOMPUTENEON_ENABLED) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 82 | template<class FuncType, class... Args> |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 83 | inline bool IsWorkloadSupported(FuncType& func, Optional<std::string&> reasonIfUnsupported, Args&&... args) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 84 | { |
| 85 | arm_compute::Status aclStatus = func(std::forward<Args>(args)...); |
| 86 | const bool supported = (aclStatus.error_code() == arm_compute::ErrorCode::OK); |
| 87 | if (!supported && reasonIfUnsupported) |
| 88 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 89 | reasonIfUnsupported.value() = aclStatus.error_description(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 90 | } |
| 91 | return supported; |
| 92 | } |
| 93 | |
| 94 | #define FORWARD_WORKLOAD_VALIDATE_FUNC(func, reasonIfUnsupported, ...) \ |
| 95 | return IsWorkloadSupported(func, reasonIfUnsupported, __VA_ARGS__); |
| 96 | #else |
| 97 | #define FORWARD_WORKLOAD_VALIDATE_FUNC(func, reasonIfUnsupported, ...) \ |
| 98 | return IsNeonBackendSupported(reasonIfUnsupported); |
| 99 | #endif |
| 100 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 101 | } // anonymous namespace |
| 102 | |
| 103 | bool NeonLayerSupport::IsActivationSupported(const TensorInfo& input, |
| 104 | const TensorInfo& output, |
| 105 | const ActivationDescriptor& descriptor, |
| 106 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 107 | { |
| 108 | ignore_unused(descriptor); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 109 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonActivationWorkloadValidate, |
| 110 | reasonIfUnsupported, |
| 111 | input, |
| 112 | output, |
| 113 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 114 | } |
| 115 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 116 | bool NeonLayerSupport::IsAdditionSupported(const TensorInfo& input0, |
| 117 | const TensorInfo& input1, |
| 118 | const TensorInfo& output, |
| 119 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 120 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 121 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonAdditionWorkloadValidate, |
| 122 | reasonIfUnsupported, |
| 123 | input0, |
| 124 | input1, |
| 125 | output); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 126 | } |
| 127 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 128 | bool NeonLayerSupport::IsBatchNormalizationSupported(const TensorInfo& input, |
| 129 | const TensorInfo& output, |
| 130 | const TensorInfo& mean, |
| 131 | const TensorInfo& var, |
| 132 | const TensorInfo& beta, |
| 133 | const TensorInfo& gamma, |
| 134 | const BatchNormalizationDescriptor& descriptor, |
| 135 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 136 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 137 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonBatchNormalizationValidate, |
| 138 | reasonIfUnsupported, |
| 139 | input, |
| 140 | output, |
| 141 | mean, |
| 142 | var, |
| 143 | beta, |
| 144 | gamma, |
| 145 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 146 | } |
| 147 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 148 | bool NeonLayerSupport::IsConstantSupported(const TensorInfo& output, |
| 149 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 150 | { |
| 151 | return IsSupportedForDataTypeNeon(reasonIfUnsupported, |
| 152 | output.GetDataType(), |
| 153 | &TrueFunc<>, |
| 154 | &TrueFunc<>); |
| 155 | } |
| 156 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 157 | bool NeonLayerSupport::IsConvertFp16ToFp32Supported(const TensorInfo& input, |
| 158 | const TensorInfo& output, |
| 159 | Optional<std::string&> reasonIfUnsupported) const |
| 160 | { |
| 161 | ignore_unused(input); |
| 162 | ignore_unused(output); |
| 163 | ignore_unused(reasonIfUnsupported); |
| 164 | return true; |
| 165 | } |
| 166 | |
| 167 | bool NeonLayerSupport::IsConvertFp32ToFp16Supported(const TensorInfo& input, |
| 168 | const TensorInfo& output, |
| 169 | Optional<std::string&> reasonIfUnsupported) const |
| 170 | { |
| 171 | ignore_unused(input); |
| 172 | ignore_unused(output); |
| 173 | ignore_unused(reasonIfUnsupported); |
| 174 | return true; |
| 175 | } |
| 176 | |
| 177 | bool NeonLayerSupport::IsConvolution2dSupported(const TensorInfo& input, |
| 178 | const TensorInfo& output, |
| 179 | const Convolution2dDescriptor& descriptor, |
| 180 | const TensorInfo& weights, |
| 181 | const Optional<TensorInfo>& biases, |
| 182 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 183 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 184 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonConvolution2dWorkloadValidate, |
| 185 | reasonIfUnsupported, |
| 186 | input, |
| 187 | output, |
| 188 | descriptor, |
| 189 | weights, |
| 190 | biases); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 191 | } |
| 192 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 193 | bool NeonLayerSupport::IsDepthwiseConvolutionSupported(const TensorInfo& input, |
| 194 | const TensorInfo& output, |
| 195 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 196 | const TensorInfo& weights, |
| 197 | const Optional<TensorInfo>& biases, |
| 198 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 199 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 200 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonDepthwiseConvolutionWorkloadValidate, |
| 201 | reasonIfUnsupported, |
| 202 | input, |
| 203 | output, |
| 204 | descriptor, |
| 205 | weights, |
| 206 | biases); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 207 | } |
| 208 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 209 | bool NeonLayerSupport::IsFloorSupported(const TensorInfo& input, |
| 210 | const TensorInfo& output, |
| 211 | Optional<std::string&> reasonIfUnsupported) const |
| 212 | { |
| 213 | ignore_unused(output); |
| 214 | return IsNeonBackendSupported(reasonIfUnsupported) && |
| 215 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 216 | input.GetDataType(), |
| 217 | &FalseFuncF16<>, |
| 218 | &TrueFunc<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 219 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 220 | &FalseFuncI32<>, |
| 221 | &FalseFuncU8<>); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | bool NeonLayerSupport::IsFullyConnectedSupported(const TensorInfo& input, |
| 225 | const TensorInfo& output, |
| 226 | const TensorInfo& weights, |
| 227 | const TensorInfo& biases, |
| 228 | const FullyConnectedDescriptor& 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(NeonFullyConnectedWorkloadValidate, |
| 232 | reasonIfUnsupported, |
| 233 | input, |
| 234 | output, |
| 235 | weights, |
| 236 | biases, |
| 237 | descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 238 | } |
| 239 | |
kevmay01 | eed8592 | 2019-01-28 08:37:25 +0000 | [diff] [blame] | 240 | bool NeonLayerSupport::IsGreaterSupported(const armnn::TensorInfo& input0, |
| 241 | const armnn::TensorInfo& input1, |
| 242 | const armnn::TensorInfo& output, |
| 243 | armnn::Optional<std::string&> reasonIfUnsupported) const |
| 244 | { |
| 245 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonGreaterWorkloadValidate, |
| 246 | reasonIfUnsupported, |
| 247 | input0, |
| 248 | input1, |
| 249 | output); |
| 250 | } |
| 251 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 252 | bool NeonLayerSupport::IsInputSupported(const TensorInfo& input, |
| 253 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 254 | { |
| 255 | return IsSupportedForDataTypeNeon(reasonIfUnsupported, |
| 256 | input.GetDataType(), |
| 257 | &TrueFunc<>, |
| 258 | &TrueFunc<>); |
| 259 | } |
| 260 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 261 | bool NeonLayerSupport::IsL2NormalizationSupported(const TensorInfo& input, |
| 262 | const TensorInfo& output, |
| 263 | const L2NormalizationDescriptor& descriptor, |
| 264 | Optional<std::string&> reasonIfUnsupported) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 265 | { |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 266 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonL2NormalizationWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 267 | } |
| 268 | |
Nattapat Chaimanowong | 4e6597a | 2018-12-20 14:14:06 +0000 | [diff] [blame] | 269 | bool NeonLayerSupport::IsMaximumSupported(const TensorInfo& input0, |
| 270 | const TensorInfo& input1, |
| 271 | const TensorInfo& output, |
| 272 | Optional<std::string&> reasonIfUnsupported) const |
| 273 | { |
| 274 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMaximumWorkloadValidate, |
| 275 | reasonIfUnsupported, |
| 276 | input0, |
| 277 | input1, |
| 278 | output); |
| 279 | } |
| 280 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 281 | bool NeonLayerSupport::IsMeanSupported(const TensorInfo& input, |
| 282 | const TensorInfo& output, |
| 283 | const MeanDescriptor& descriptor, |
| 284 | Optional<std::string&> reasonIfUnsupported) const |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 285 | { |
Matthew Bentham | fd89996 | 2018-12-31 15:49:42 +0000 | [diff] [blame] | 286 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMeanWorkloadValidate, |
| 287 | reasonIfUnsupported, |
| 288 | input, |
| 289 | output, |
| 290 | descriptor); |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 291 | } |
| 292 | |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 293 | bool NeonLayerSupport::IsMemCopySupported(const TensorInfo &input, |
| 294 | const TensorInfo &output, |
| 295 | Optional<std::string &> reasonIfUnsupported) const |
| 296 | { |
| 297 | ignore_unused(input); |
| 298 | ignore_unused(output); |
| 299 | return true; |
| 300 | } |
| 301 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 302 | bool NeonLayerSupport::IsMergerSupported(const std::vector<const TensorInfo*> inputs, |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 303 | const TensorInfo& output, |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 304 | const OriginsDescriptor& descriptor, |
| 305 | Optional<std::string&> reasonIfUnsupported) const |
| 306 | { |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 307 | if(descriptor.GetNumDimensions() - descriptor.GetConcatAxis() == 1) |
| 308 | { |
| 309 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMergerWorkloadValidate, |
| 310 | reasonIfUnsupported, |
| 311 | inputs, |
| 312 | output, |
| 313 | descriptor); |
| 314 | } |
| 315 | else |
| 316 | { |
| 317 | return IsSupportedForDataTypeNeon(reasonIfUnsupported, |
| 318 | inputs[0]->GetDataType(), |
| 319 | &TrueFunc<>, |
| 320 | &TrueFunc<>); |
| 321 | } |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 322 | } |
| 323 | |
Conor Kennedy | 54b2169 | 2019-01-09 07:57:38 +0000 | [diff] [blame] | 324 | bool NeonLayerSupport::IsMinimumSupported(const TensorInfo& input0, |
| 325 | const TensorInfo& input1, |
| 326 | const TensorInfo& output, |
| 327 | Optional<std::string&> reasonIfUnsupported) const |
| 328 | { |
| 329 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMinimumWorkloadValidate, |
| 330 | reasonIfUnsupported, |
| 331 | input0, |
| 332 | input1, |
| 333 | output); |
| 334 | } |
| 335 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 336 | bool NeonLayerSupport::IsMultiplicationSupported(const TensorInfo& input0, |
| 337 | const TensorInfo& input1, |
| 338 | const TensorInfo& output, |
| 339 | Optional<std::string&> reasonIfUnsupported) const |
| 340 | { |
| 341 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonMultiplicationWorkloadValidate, |
| 342 | reasonIfUnsupported, |
| 343 | input0, |
| 344 | input1, |
| 345 | output); |
| 346 | } |
| 347 | |
| 348 | bool NeonLayerSupport::IsNormalizationSupported(const TensorInfo& input, |
| 349 | const TensorInfo& output, |
| 350 | const NormalizationDescriptor& descriptor, |
| 351 | Optional<std::string&> reasonIfUnsupported) const |
| 352 | { |
| 353 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonNormalizationWorkloadValidate, |
| 354 | reasonIfUnsupported, |
| 355 | input, |
| 356 | output, |
| 357 | descriptor); |
| 358 | } |
| 359 | |
| 360 | bool NeonLayerSupport::IsOutputSupported(const TensorInfo& output, |
| 361 | Optional<std::string&> reasonIfUnsupported) const |
| 362 | { |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 363 | return IsNeonBackendSupported(reasonIfUnsupported) && |
| 364 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 365 | output.GetDataType(), |
| 366 | &TrueFunc<>, |
| 367 | &TrueFunc<>, |
| 368 | &TrueFunc<>, |
| 369 | &FalseFuncI32<>, |
| 370 | &TrueFunc<>); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 371 | } |
| 372 | |
Éanna Ó Catháin | 1205574 | 2019-01-25 10:01:40 +0000 | [diff] [blame] | 373 | bool NeonLayerSupport::IsPadSupported(const TensorInfo& input, |
| 374 | const TensorInfo& output, |
| 375 | const PadDescriptor& descriptor, |
| 376 | Optional<std::string&> reasonIfUnsupported) const |
| 377 | { |
| 378 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonPadWorkloadValidate, |
| 379 | reasonIfUnsupported, |
| 380 | input, |
| 381 | output, |
| 382 | descriptor); |
| 383 | } |
| 384 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 385 | bool NeonLayerSupport::IsPermuteSupported(const TensorInfo& input, |
| 386 | const TensorInfo& output, |
| 387 | const PermuteDescriptor& descriptor, |
| 388 | Optional<std::string&> reasonIfUnsupported) const |
| 389 | { |
| 390 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonPermuteWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 391 | } |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 392 | |
| 393 | bool NeonLayerSupport::IsPooling2dSupported(const TensorInfo& input, |
| 394 | const TensorInfo& output, |
| 395 | const Pooling2dDescriptor& descriptor, |
| 396 | Optional<std::string&> reasonIfUnsupported) const |
| 397 | { |
| 398 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonPooling2dWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 399 | } |
| 400 | |
| 401 | bool NeonLayerSupport::IsReshapeSupported(const TensorInfo& input, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 402 | const ReshapeDescriptor& descriptor, |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 403 | Optional<std::string&> reasonIfUnsupported) const |
| 404 | { |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 405 | ignore_unused(descriptor); |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 406 | return IsSupportedForDataTypeNeon(reasonIfUnsupported, |
| 407 | input.GetDataType(), |
| 408 | &TrueFunc<>, |
| 409 | &TrueFunc<>); |
| 410 | } |
| 411 | |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame] | 412 | bool NeonLayerSupport::IsResizeBilinearSupported(const TensorInfo& input, |
| 413 | const TensorInfo& output, |
| 414 | Optional<std::string&> reasonIfUnsupported) const |
| 415 | { |
| 416 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonResizeBilinearWorkloadValidate, |
| 417 | reasonIfUnsupported, |
| 418 | input, |
| 419 | output); |
| 420 | } |
| 421 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 422 | bool NeonLayerSupport::IsSoftmaxSupported(const TensorInfo& input, |
| 423 | const TensorInfo& output, |
| 424 | const SoftmaxDescriptor& descriptor, |
| 425 | Optional<std::string&> reasonIfUnsupported) const |
| 426 | { |
| 427 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSoftmaxWorkloadValidate, reasonIfUnsupported, input, output, descriptor); |
| 428 | } |
| 429 | |
| 430 | bool NeonLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 431 | const ViewsDescriptor& descriptor, |
| 432 | Optional<std::string&> reasonIfUnsupported) const |
| 433 | { |
| 434 | ignore_unused(descriptor); |
| 435 | return IsSupportedForDataTypeNeon(reasonIfUnsupported, |
| 436 | input.GetDataType(), |
| 437 | &TrueFunc<>, |
| 438 | &TrueFunc<>); |
| 439 | } |
| 440 | |
| 441 | bool NeonLayerSupport::IsSubtractionSupported(const TensorInfo& input0, |
| 442 | const TensorInfo& input1, |
| 443 | const TensorInfo& output, |
| 444 | Optional<std::string&> reasonIfUnsupported) const |
| 445 | { |
| 446 | FORWARD_WORKLOAD_VALIDATE_FUNC(NeonSubtractionWorkloadValidate, |
| 447 | reasonIfUnsupported, |
| 448 | input0, |
| 449 | input1, |
| 450 | output); |
| 451 | } |
| 452 | |
Aron Virginas-Tar | fc82431 | 2018-10-15 15:00:13 +0100 | [diff] [blame] | 453 | } // namespace armnn |