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