telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
Mike Kelly | 3ec3077 | 2023-03-08 13:47:17 +0000 | [diff] [blame] | 2 | // Copyright © 2017-2023 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 "RefLayerSupport.hpp" |
David Beck | 3cc9a62 | 2018-10-12 10:38:31 +0100 | [diff] [blame] | 7 | |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 8 | #include <armnn/TypesUtils.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 9 | #include <armnn/Types.hpp> |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 10 | #include <armnn/utility/IgnoreUnused.hpp> |
Matthew Sloyan | 171214c | 2020-09-09 09:07:37 +0100 | [diff] [blame] | 11 | #include <armnn/utility/NumericCast.hpp> |
Cathal Corbett | 34b429c | 2021-12-24 12:24:40 +0000 | [diff] [blame] | 12 | #include <armnn/utility/PolymorphicDowncast.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 13 | |
Matteo Martincigh | e011d20 | 2019-11-28 11:35:47 +0000 | [diff] [blame] | 14 | #include <LayerSupportCommon.hpp> |
Derek Lamberti | f674aa0 | 2019-08-01 15:56:25 +0100 | [diff] [blame] | 15 | #include <backendsCommon/LayerSupportRules.hpp> |
Matteo Martincigh | e011d20 | 2019-11-28 11:35:47 +0000 | [diff] [blame] | 16 | |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 17 | #include <vector> |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 18 | #include <array> |
| 19 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 20 | namespace armnn |
| 21 | { |
| 22 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 23 | namespace |
| 24 | { |
| 25 | |
| 26 | template<typename Float32Func, typename Uint8Func, typename ... Params> |
| 27 | bool IsSupportedForDataTypeRef(Optional<std::string&> reasonIfUnsupported, |
| 28 | DataType dataType, |
| 29 | Float32Func floatFuncPtr, |
| 30 | Uint8Func uint8FuncPtr, |
| 31 | Params&&... params) |
| 32 | { |
| 33 | return IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 34 | dataType, |
| 35 | &FalseFunc<Params...>, |
| 36 | floatFuncPtr, |
| 37 | uint8FuncPtr, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 38 | &FalseFunc<Params...>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 39 | &FalseFunc<Params...>, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 40 | std::forward<Params>(params)...); |
| 41 | } |
| 42 | |
| 43 | } // anonymous namespace |
| 44 | |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 45 | namespace |
| 46 | { |
| 47 | |
| 48 | std::string CreateIncorrectDimensionsErrorMsg(unsigned int expected, |
| 49 | unsigned int actual, |
| 50 | std::string& layerStr, |
| 51 | std::string& tensorName) |
| 52 | { |
| 53 | std::string errorMsg = "Reference " + layerStr + ": Expected " + std::to_string(expected) + " dimensions but got" + |
| 54 | " " + std::to_string(actual) + " dimensions instead, for the '" + tensorName + "' tensor."; |
| 55 | |
| 56 | return errorMsg; |
| 57 | } |
| 58 | |
| 59 | } // anonymous namespace |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 60 | |
Cathal Corbett | 34b429c | 2021-12-24 12:24:40 +0000 | [diff] [blame] | 61 | bool RefLayerSupport::IsLayerSupported(const LayerType& type, |
| 62 | const std::vector<TensorInfo>& infos, |
| 63 | const BaseDescriptor& descriptor, |
| 64 | const Optional<LstmInputParamsInfo>& lstmParamsInfo, |
| 65 | const Optional<QuantizedLstmInputParamsInfo>& quantizedLstmInputParamsInfo, |
| 66 | Optional<std::string&> reasonIfUnsupported) const |
| 67 | { |
| 68 | switch (type) |
| 69 | { |
| 70 | case LayerType::Activation: |
| 71 | return IsActivationSupported(infos[0], |
| 72 | infos[1], |
| 73 | *(PolymorphicDowncast<const ActivationDescriptor*>(&descriptor)), |
| 74 | reasonIfUnsupported); |
| 75 | case LayerType::Addition: |
| 76 | return IsAdditionSupported(infos[0], infos[1], infos[2], reasonIfUnsupported); |
| 77 | case LayerType::ArgMinMax: |
| 78 | return IsArgMinMaxSupported(infos[0], |
| 79 | infos[1], |
| 80 | *(PolymorphicDowncast<const ArgMinMaxDescriptor*>(&descriptor)), |
| 81 | reasonIfUnsupported); |
Samuel Yap | 6b47809 | 2022-07-06 15:36:03 +0100 | [diff] [blame] | 82 | case LayerType::BatchMatMul: |
| 83 | return IsBatchMatMulSupported(infos[0], |
| 84 | infos[1], |
| 85 | infos[2], |
| 86 | *(PolymorphicDowncast<const BatchMatMulDescriptor*>(&descriptor)), |
| 87 | reasonIfUnsupported); |
Cathal Corbett | 34b429c | 2021-12-24 12:24:40 +0000 | [diff] [blame] | 88 | case LayerType::BatchNormalization: |
| 89 | return IsBatchNormalizationSupported(infos[0], |
| 90 | infos[1], |
| 91 | infos[2], |
| 92 | infos[3], |
| 93 | infos[4], |
| 94 | infos[5], |
| 95 | *(PolymorphicDowncast<const BatchNormalizationDescriptor*> |
| 96 | (&descriptor)), |
| 97 | reasonIfUnsupported); |
| 98 | case LayerType::BatchToSpaceNd: |
| 99 | return IsBatchToSpaceNdSupported(infos[0], |
| 100 | infos[1], |
| 101 | *(PolymorphicDowncast<const BatchToSpaceNdDescriptor*>(&descriptor)), |
| 102 | reasonIfUnsupported); |
| 103 | case LayerType::Comparison: |
| 104 | return IsComparisonSupported(infos[0], |
| 105 | infos[1], |
| 106 | infos[2], |
| 107 | *(PolymorphicDowncast<const ComparisonDescriptor*>(&descriptor)), |
| 108 | reasonIfUnsupported); |
| 109 | case LayerType::Concat: |
| 110 | { |
| 111 | std::vector<const TensorInfo*> inputInfos; |
| 112 | for (uint32_t i = 0; i < (infos.size() - 1); i++) |
| 113 | { |
| 114 | inputInfos.push_back(&infos[i]); |
| 115 | } |
| 116 | return IsConcatSupported(inputInfos, |
| 117 | infos[infos.size() - 1], |
| 118 | *(PolymorphicDowncast<const OriginsDescriptor*>(&descriptor)), |
| 119 | reasonIfUnsupported); |
| 120 | } |
| 121 | case LayerType::Constant: |
| 122 | return IsConstantSupported(infos[0], reasonIfUnsupported); |
Cathal Corbett | 34b429c | 2021-12-24 12:24:40 +0000 | [diff] [blame] | 123 | case LayerType::ConvertFp16ToFp32: |
| 124 | return IsConvertFp16ToFp32Supported(infos[0], infos[1], reasonIfUnsupported); |
Cathal Corbett | 34b429c | 2021-12-24 12:24:40 +0000 | [diff] [blame] | 125 | case LayerType::ConvertFp32ToFp16: |
| 126 | return IsConvertFp32ToFp16Supported(infos[0], infos[1], reasonIfUnsupported); |
| 127 | case LayerType::Convolution2d: |
| 128 | { |
| 129 | if (infos.size() != 4) |
| 130 | { |
| 131 | throw InvalidArgumentException("Invalid number of Convolution2d TensorInfos. " |
| 132 | "TensorInfos should be of format: {input, output, weights, biases}."); |
| 133 | } |
| 134 | |
| 135 | auto desc = *(PolymorphicDowncast<const Convolution2dDescriptor*>(&descriptor)); |
| 136 | if (infos[3] == TensorInfo()) |
| 137 | { |
| 138 | return IsConvolution2dSupported(infos[0], |
| 139 | infos[1], |
| 140 | desc, |
| 141 | infos[2], |
| 142 | EmptyOptional(), |
| 143 | reasonIfUnsupported); |
| 144 | } |
| 145 | else |
| 146 | { |
| 147 | return IsConvolution2dSupported(infos[0], |
| 148 | infos[1], |
| 149 | desc, |
| 150 | infos[2], |
| 151 | infos[3], |
| 152 | reasonIfUnsupported); |
| 153 | } |
| 154 | } |
| 155 | case LayerType::DepthToSpace: |
| 156 | return IsDepthToSpaceSupported(infos[0], |
| 157 | infos[1], |
| 158 | *(PolymorphicDowncast<const DepthToSpaceDescriptor*>(&descriptor)), |
| 159 | reasonIfUnsupported); |
| 160 | case LayerType::DepthwiseConvolution2d: |
| 161 | { |
| 162 | if (infos.size() != 4) |
| 163 | { |
| 164 | throw InvalidArgumentException("Invalid number of DepthwiseConvolution2d TensorInfos. " |
| 165 | "TensorInfos should be of format: {input, output, weights, biases}."); |
| 166 | } |
| 167 | |
| 168 | auto desc = *(PolymorphicDowncast<const DepthwiseConvolution2dDescriptor*>(&descriptor)); |
| 169 | if (infos[3] == TensorInfo()) |
| 170 | { |
| 171 | return IsDepthwiseConvolutionSupported(infos[0], |
| 172 | infos[1], |
| 173 | desc, |
| 174 | infos[2], |
| 175 | EmptyOptional(), |
| 176 | reasonIfUnsupported); |
| 177 | } |
| 178 | else |
| 179 | { |
| 180 | return IsDepthwiseConvolutionSupported(infos[0], |
| 181 | infos[1], |
| 182 | desc, |
| 183 | infos[2], |
| 184 | infos[3], |
| 185 | reasonIfUnsupported); |
| 186 | } |
| 187 | } |
| 188 | case LayerType::Dequantize: |
| 189 | return IsDequantizeSupported(infos[0], infos[1], reasonIfUnsupported); |
| 190 | case LayerType::Division: |
| 191 | return IsDivisionSupported(infos[0], infos[1], infos[2], reasonIfUnsupported); |
Mike Kelly | 3ec3077 | 2023-03-08 13:47:17 +0000 | [diff] [blame] | 192 | case LayerType::ElementwiseBinary: |
| 193 | { |
| 194 | std::array<DataType, 7> supportedTypes = |
| 195 | { |
| 196 | DataType::Float32, |
| 197 | DataType::Float16, |
| 198 | DataType::QAsymmS8, |
| 199 | DataType::QAsymmU8, |
| 200 | DataType::QSymmS16, |
| 201 | DataType::Signed32 |
| 202 | }; |
| 203 | |
| 204 | bool supported = true; |
| 205 | supported &= CheckSupportRule(TypeAnyOf(infos[0], supportedTypes), reasonIfUnsupported, |
| 206 | "Reference elementwise unary: input type not supported"); |
| 207 | |
| 208 | supported &= CheckSupportRule(TypeAnyOf(infos[1], supportedTypes), reasonIfUnsupported, |
| 209 | "Reference elementwise unary: input type not supported"); |
| 210 | |
| 211 | supported &= CheckSupportRule(TypeAnyOf(infos[2], supportedTypes), reasonIfUnsupported, |
| 212 | "Reference elementwise unary: output type not supported"); |
| 213 | |
| 214 | supported &= CheckSupportRule(TypesAreEqual(infos[0], infos[1]), reasonIfUnsupported, |
| 215 | "Reference elementwise unary: input types not matching"); |
| 216 | |
| 217 | supported &= CheckSupportRule(TypesAreEqual(infos[0], infos[2]), reasonIfUnsupported, |
| 218 | "Reference elementwise unary: input and output types not matching"); |
| 219 | |
| 220 | return supported; |
| 221 | } |
Cathal Corbett | 34b429c | 2021-12-24 12:24:40 +0000 | [diff] [blame] | 222 | case LayerType::ElementwiseUnary: |
| 223 | return IsElementwiseUnarySupported(infos[0], |
| 224 | infos[1], |
| 225 | *(PolymorphicDowncast<const ElementwiseUnaryDescriptor*>(&descriptor)), |
| 226 | reasonIfUnsupported); |
| 227 | case LayerType::Fill: |
| 228 | return IsFillSupported(infos[0], |
| 229 | infos[1], |
| 230 | *(PolymorphicDowncast<const FillDescriptor*>(&descriptor)), |
| 231 | reasonIfUnsupported); |
| 232 | case LayerType::Floor: |
| 233 | return IsFloorSupported(infos[0], infos[1], reasonIfUnsupported); |
| 234 | case LayerType::FullyConnected: |
| 235 | return IsFullyConnectedSupported(infos[0], |
| 236 | infos[1], |
| 237 | infos[2], |
| 238 | infos[3], |
| 239 | *(PolymorphicDowncast<const FullyConnectedDescriptor*>(&descriptor)), |
| 240 | reasonIfUnsupported); |
| 241 | case LayerType::Gather: |
| 242 | return IsGatherSupported(infos[0], |
| 243 | infos[1], |
| 244 | infos[2], |
| 245 | *(PolymorphicDowncast<const GatherDescriptor*>(&descriptor)), |
| 246 | reasonIfUnsupported); |
Teresa Charlin | b2d3ec5 | 2022-04-12 22:07:09 +0100 | [diff] [blame] | 247 | case LayerType::GatherNd: |
| 248 | return IsGatherNdSupported(infos[0], |
| 249 | infos[1], |
| 250 | infos[2], |
| 251 | reasonIfUnsupported); |
Cathal Corbett | 34b429c | 2021-12-24 12:24:40 +0000 | [diff] [blame] | 252 | case LayerType::Input: |
| 253 | return IsInputSupported(infos[0], reasonIfUnsupported); |
| 254 | case LayerType::InstanceNormalization: |
| 255 | return IsInstanceNormalizationSupported(infos[0], |
| 256 | infos[1], |
| 257 | *(PolymorphicDowncast<const InstanceNormalizationDescriptor*> |
| 258 | (&descriptor)), |
| 259 | reasonIfUnsupported); |
| 260 | case LayerType::L2Normalization: |
| 261 | return IsL2NormalizationSupported(infos[0], |
| 262 | infos[1], |
| 263 | *(PolymorphicDowncast<const L2NormalizationDescriptor*>(&descriptor)), |
| 264 | reasonIfUnsupported); |
| 265 | case LayerType::LogicalBinary: |
| 266 | return IsLogicalBinarySupported(infos[0], |
| 267 | infos[1], |
| 268 | infos[2], |
| 269 | *(PolymorphicDowncast<const LogicalBinaryDescriptor*>(&descriptor)), |
| 270 | reasonIfUnsupported); |
| 271 | case LayerType::LogSoftmax: |
| 272 | return IsLogSoftmaxSupported(infos[0], |
| 273 | infos[1], |
| 274 | *(PolymorphicDowncast<const LogSoftmaxDescriptor*>(&descriptor)), |
| 275 | reasonIfUnsupported); |
| 276 | case LayerType::Lstm: |
| 277 | return IsLstmSupported(infos[0], |
| 278 | infos[1], |
| 279 | infos[2], |
| 280 | infos[3], |
| 281 | infos[4], |
| 282 | infos[5], |
| 283 | infos[6], |
| 284 | *(PolymorphicDowncast<const LstmDescriptor*>(&descriptor)), |
| 285 | lstmParamsInfo.value(), |
| 286 | reasonIfUnsupported); |
| 287 | case LayerType::QLstm: |
| 288 | return IsQLstmSupported(infos[0], |
| 289 | infos[1], |
| 290 | infos[2], |
| 291 | infos[3], |
| 292 | infos[4], |
| 293 | infos[5], |
| 294 | *(PolymorphicDowncast<const QLstmDescriptor*>(&descriptor)), |
| 295 | lstmParamsInfo.value(), |
| 296 | reasonIfUnsupported); |
| 297 | case LayerType::Maximum: |
| 298 | return IsMaximumSupported(infos[0], infos[1], infos[2], reasonIfUnsupported); |
| 299 | case LayerType::Mean: |
| 300 | return IsMeanSupported(infos[0], |
| 301 | infos[1], |
| 302 | *(PolymorphicDowncast<const MeanDescriptor*>(&descriptor)), |
| 303 | reasonIfUnsupported); |
| 304 | case LayerType::Minimum: |
| 305 | return IsMinimumSupported(infos[0], infos[1], infos[2], reasonIfUnsupported); |
| 306 | case LayerType::Multiplication: |
| 307 | return IsMultiplicationSupported(infos[0], infos[1], infos[2], reasonIfUnsupported); |
| 308 | case LayerType::Normalization: |
| 309 | return IsNormalizationSupported(infos[0], |
| 310 | infos[1], |
| 311 | *(PolymorphicDowncast<const NormalizationDescriptor*>(&descriptor)), |
| 312 | reasonIfUnsupported); |
| 313 | case LayerType::Output: |
| 314 | return IsOutputSupported(infos[0], reasonIfUnsupported); |
| 315 | case LayerType::Pad: |
| 316 | return IsPadSupported(infos[0], |
| 317 | infos[1], |
| 318 | *(PolymorphicDowncast<const PadDescriptor*>(&descriptor)), |
| 319 | reasonIfUnsupported); |
| 320 | case LayerType::Permute: |
| 321 | return IsPermuteSupported(infos[0], |
| 322 | infos[1], |
| 323 | *(PolymorphicDowncast<const PermuteDescriptor*>(&descriptor)), |
| 324 | reasonIfUnsupported); |
| 325 | case LayerType::Pooling2d: |
| 326 | return IsPooling2dSupported(infos[0], |
| 327 | infos[1], |
| 328 | *(PolymorphicDowncast<const Pooling2dDescriptor*>(&descriptor)), |
| 329 | reasonIfUnsupported); |
| 330 | case LayerType::Prelu: |
| 331 | return IsPreluSupported(infos[0], infos[1], infos[2], reasonIfUnsupported); |
| 332 | case LayerType::Quantize: |
| 333 | return IsQuantizeSupported(infos[0], infos[1], reasonIfUnsupported); |
| 334 | case LayerType::Reshape: |
| 335 | return IsReshapeSupported(infos[0], |
| 336 | infos[1], |
| 337 | *(PolymorphicDowncast<const ReshapeDescriptor*>(&descriptor)), |
| 338 | reasonIfUnsupported); |
| 339 | case LayerType::Resize: |
| 340 | return IsResizeSupported(infos[0], |
| 341 | infos[1], |
| 342 | *(PolymorphicDowncast<const ResizeDescriptor*>(&descriptor)), |
| 343 | reasonIfUnsupported); |
Tianle Cheng | 988354d | 2023-06-28 13:20:47 +0100 | [diff] [blame] | 344 | case LayerType::ReverseV2: |
| 345 | return IsReverseV2Supported(infos[0], |
| 346 | infos[1], |
Tracy Narine | bb8d759 | 2023-07-13 16:50:54 +0100 | [diff] [blame] | 347 | infos[2], |
Tianle Cheng | 988354d | 2023-06-28 13:20:47 +0100 | [diff] [blame] | 348 | reasonIfUnsupported); |
Cathal Corbett | 34b429c | 2021-12-24 12:24:40 +0000 | [diff] [blame] | 349 | case LayerType::Reduce: |
| 350 | return IsReduceSupported(infos[0], |
| 351 | infos[1], |
| 352 | *(PolymorphicDowncast<const ReduceDescriptor*>(&descriptor)), |
| 353 | reasonIfUnsupported); |
| 354 | case LayerType::Slice: |
| 355 | return IsSliceSupported(infos[0], |
| 356 | infos[1], |
| 357 | *(PolymorphicDowncast<const SliceDescriptor*>(&descriptor)), |
| 358 | reasonIfUnsupported); |
| 359 | case LayerType::Softmax: |
| 360 | return IsSoftmaxSupported(infos[0], |
| 361 | infos[1], |
| 362 | *(PolymorphicDowncast<const SoftmaxDescriptor*>(&descriptor)), |
| 363 | reasonIfUnsupported); |
| 364 | case LayerType::SpaceToBatchNd: |
| 365 | return IsSpaceToBatchNdSupported(infos[0], |
| 366 | infos[1], |
| 367 | *(PolymorphicDowncast<const SpaceToBatchNdDescriptor*>(&descriptor)), |
| 368 | reasonIfUnsupported); |
| 369 | case LayerType::SpaceToDepth: |
| 370 | return IsSpaceToDepthSupported(infos[0], |
| 371 | infos[1], |
| 372 | *(PolymorphicDowncast<const SpaceToDepthDescriptor*>(&descriptor)), |
| 373 | reasonIfUnsupported); |
| 374 | case LayerType::Splitter: |
| 375 | { |
| 376 | std::vector<TensorInfo> outputInfos; |
| 377 | for (uint32_t i = 1; i < infos.size(); i++) |
| 378 | { |
| 379 | outputInfos.push_back(infos[i]); |
| 380 | } |
| 381 | return IsSplitterSupported(infos[0], |
| 382 | {outputInfos.begin(), outputInfos.end()}, |
| 383 | *(PolymorphicDowncast<const ViewsDescriptor*>(&descriptor)), |
| 384 | reasonIfUnsupported); |
| 385 | } |
| 386 | case LayerType::Stack: |
| 387 | { |
| 388 | std::vector<const TensorInfo*> inputInfos; |
| 389 | for (uint32_t i = 0; i < infos.size() - 1; i++) |
| 390 | { |
| 391 | inputInfos.push_back(&infos[i]); |
| 392 | } |
| 393 | return IsStackSupported(inputInfos, |
| 394 | infos[infos.size() - 1], |
| 395 | *(PolymorphicDowncast<const StackDescriptor*>(&descriptor)), |
| 396 | reasonIfUnsupported); |
| 397 | } |
| 398 | case LayerType::StridedSlice: |
| 399 | return IsStridedSliceSupported(infos[0], |
| 400 | infos[1], |
| 401 | *(PolymorphicDowncast<const StridedSliceDescriptor*>(&descriptor)), |
| 402 | reasonIfUnsupported); |
| 403 | case LayerType::Subtraction: |
| 404 | return IsSubtractionSupported(infos[0], infos[1], infos[2], reasonIfUnsupported); |
Teresa Charlin | 79a06a5 | 2023-07-13 17:16:45 +0100 | [diff] [blame] | 405 | case LayerType::Tile: |
| 406 | return IsTileSupported(infos[0], |
| 407 | infos[1], |
| 408 | *(PolymorphicDowncast<const TileDescriptor*>(&descriptor)), |
| 409 | reasonIfUnsupported); |
Cathal Corbett | 34b429c | 2021-12-24 12:24:40 +0000 | [diff] [blame] | 410 | case LayerType::Transpose: |
| 411 | return IsTransposeSupported(infos[0], |
| 412 | infos[1], |
| 413 | *(PolymorphicDowncast<const TransposeDescriptor*>(&descriptor)), |
| 414 | reasonIfUnsupported); |
| 415 | case LayerType::TransposeConvolution2d: |
| 416 | { |
| 417 | if (infos.size() != 4) |
| 418 | { |
| 419 | throw InvalidArgumentException("Invalid number of TransposeConvolution2d TensorInfos. " |
| 420 | "TensorInfos should be of format: {input, output, weights, biases}."); |
| 421 | } |
| 422 | |
| 423 | auto desc = *(PolymorphicDowncast<const TransposeConvolution2dDescriptor*>(&descriptor)); |
| 424 | if (infos[3] == TensorInfo()) |
| 425 | { |
| 426 | return IsTransposeConvolution2dSupported(infos[0], |
| 427 | infos[1], |
| 428 | desc, |
| 429 | infos[2], |
| 430 | EmptyOptional(), |
| 431 | reasonIfUnsupported); |
| 432 | } |
| 433 | else |
| 434 | { |
| 435 | return IsTransposeConvolution2dSupported(infos[0], |
| 436 | infos[1], |
| 437 | desc, |
| 438 | infos[2], |
| 439 | infos[3], |
| 440 | reasonIfUnsupported); |
| 441 | } |
| 442 | } |
| 443 | case LayerType::Cast: |
| 444 | return IsCastSupported(infos[0], infos[1], reasonIfUnsupported); |
| 445 | case LayerType::ChannelShuffle: |
| 446 | return IsChannelShuffleSupported(infos[0], |
| 447 | infos[1], |
| 448 | *(PolymorphicDowncast<const ChannelShuffleDescriptor*>(&descriptor)), |
| 449 | reasonIfUnsupported); |
| 450 | case LayerType::Convolution3d: |
| 451 | { |
| 452 | if (infos.size() != 4) |
| 453 | { |
| 454 | throw InvalidArgumentException("Invalid number of Convolution3d TensorInfos. " |
| 455 | "TensorInfos should be of format: {input, output, weights, biases}."); |
| 456 | } |
| 457 | |
| 458 | auto desc = *(PolymorphicDowncast<const Convolution3dDescriptor*>(&descriptor)); |
| 459 | if (infos[3] == TensorInfo()) |
| 460 | { |
| 461 | return IsConvolution3dSupported(infos[0], |
| 462 | infos[1], |
| 463 | desc, |
| 464 | infos[2], |
| 465 | EmptyOptional(), |
| 466 | reasonIfUnsupported); |
| 467 | } |
| 468 | else |
| 469 | { |
| 470 | return IsConvolution3dSupported(infos[0], |
| 471 | infos[1], |
| 472 | desc, |
| 473 | infos[2], |
| 474 | infos[3], |
| 475 | reasonIfUnsupported); |
| 476 | } |
| 477 | } |
| 478 | case LayerType::Debug: |
| 479 | return IsDebugSupported(infos[0], infos[1], reasonIfUnsupported); |
| 480 | case LayerType::DetectionPostProcess: |
| 481 | return IsDetectionPostProcessSupported(infos[0], |
| 482 | infos[1], |
| 483 | infos[2], |
| 484 | infos[3], |
| 485 | infos[4], |
| 486 | infos[5], |
| 487 | infos[6], |
| 488 | *(PolymorphicDowncast<const DetectionPostProcessDescriptor*> |
| 489 | (&descriptor)), |
| 490 | reasonIfUnsupported); |
| 491 | case LayerType::FakeQuantization: |
| 492 | return IsFakeQuantizationSupported(infos[0], |
| 493 | *(PolymorphicDowncast<const FakeQuantizationDescriptor*>(&descriptor)), |
| 494 | reasonIfUnsupported); |
| 495 | case LayerType::MemCopy: |
| 496 | return IsMemCopySupported(infos[0], infos[1], reasonIfUnsupported); |
| 497 | case LayerType::Rank: |
| 498 | return IsRankSupported(infos[0], infos[1], reasonIfUnsupported); |
| 499 | case LayerType::Shape: |
| 500 | return IsShapeSupported(infos[0], infos[1], reasonIfUnsupported); |
| 501 | case LayerType::UnidirectionalSequenceLstm: |
| 502 | { |
| 503 | if (infos.size() != 6) |
| 504 | { |
| 505 | throw InvalidArgumentException("Invalid number of UnidirectionalSequenceLstm TensorInfos. TensorInfos " |
| 506 | "should be of format: {input, outputStateIn, cellStateIn, " |
| 507 | "hiddenStateOutputVal, cellStateOutputVal, output}"); |
| 508 | } |
| 509 | auto desc = *(PolymorphicDowncast<const UnidirectionalSequenceLstmDescriptor*>(&descriptor)); |
Mike Kelly | 1299496 | 2022-04-21 11:57:09 +0100 | [diff] [blame] | 510 | return IsUnidirectionalSequenceLstmSupported(infos[0], |
| 511 | infos[1], |
| 512 | infos[2], |
| 513 | infos[3], |
| 514 | infos[4], |
| 515 | infos[5], |
| 516 | desc, |
| 517 | lstmParamsInfo.value(), |
| 518 | reasonIfUnsupported); |
Cathal Corbett | 34b429c | 2021-12-24 12:24:40 +0000 | [diff] [blame] | 519 | } |
| 520 | case LayerType::Pooling3d: |
| 521 | return IsPooling3dSupported(infos[0], |
| 522 | infos[1], |
| 523 | *(PolymorphicDowncast<const Pooling3dDescriptor*>(&descriptor)), |
| 524 | reasonIfUnsupported); |
| 525 | case LayerType::Map: |
| 526 | return true; |
| 527 | case LayerType::Unmap: |
| 528 | return true; |
| 529 | case LayerType::MemImport: |
| 530 | return LayerSupportBase::IsMemImportSupported(infos[0], infos[1], reasonIfUnsupported); |
| 531 | case LayerType::Merge: |
| 532 | return LayerSupportBase::IsMergeSupported(infos[0], infos[1], infos[2], reasonIfUnsupported); |
| 533 | case LayerType::QuantizedLstm: |
| 534 | return LayerSupportBase::IsQuantizedLstmSupported(infos[0], |
| 535 | infos[1], |
| 536 | infos[2], |
| 537 | infos[3], |
| 538 | infos[4], |
| 539 | quantizedLstmInputParamsInfo.value(), |
| 540 | reasonIfUnsupported); |
| 541 | default: |
| 542 | // layers not supported in neon by default: |
| 543 | // precompiled, standin, switch |
| 544 | return false; |
| 545 | } |
| 546 | } |
| 547 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 548 | bool RefLayerSupport::IsActivationSupported(const TensorInfo& input, |
| 549 | const TensorInfo& output, |
| 550 | const ActivationDescriptor& descriptor, |
| 551 | Optional<std::string&> reasonIfUnsupported) const |
| 552 | { |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 553 | bool supported = true; |
| 554 | |
| 555 | // Define supported types. |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 556 | std::array<DataType,6> supportedTypes = { |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 557 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 558 | DataType::Float16, |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 559 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 560 | DataType::QAsymmU8, |
| 561 | DataType::QSymmS16 |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 562 | }; |
| 563 | |
| 564 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 565 | "Reference activation: input type not supported."); |
| 566 | |
| 567 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 568 | "Reference activation: output type not supported."); |
| 569 | |
| 570 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 571 | "Reference activation: input and output types mismatched."); |
| 572 | |
| 573 | supported &= CheckSupportRule(ShapesAreSameRank(input, output), reasonIfUnsupported, |
| 574 | "Reference activation: input and output shapes are of different rank."); |
| 575 | |
| 576 | |
| 577 | struct ActivationFunctionSupported : public Rule |
| 578 | { |
| 579 | ActivationFunctionSupported(const ActivationDescriptor& desc) |
| 580 | { |
| 581 | switch(desc.m_Function) |
| 582 | { |
| 583 | case ActivationFunction::Abs: |
| 584 | case ActivationFunction::BoundedReLu: |
David Monahan | 3b3c381 | 2020-02-25 09:03:29 +0000 | [diff] [blame] | 585 | case ActivationFunction::Elu: |
Colm Donelan | 03fbeaf | 2020-02-26 15:39:23 +0000 | [diff] [blame] | 586 | case ActivationFunction::HardSwish: |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 587 | case ActivationFunction::LeakyReLu: |
| 588 | case ActivationFunction::Linear: |
| 589 | case ActivationFunction::ReLu: |
| 590 | case ActivationFunction::Sigmoid: |
| 591 | case ActivationFunction::SoftReLu: |
| 592 | case ActivationFunction::Sqrt: |
| 593 | case ActivationFunction::Square: |
| 594 | case ActivationFunction::TanH: |
| 595 | { |
| 596 | m_Res = true; |
| 597 | break; |
| 598 | } |
| 599 | default: |
| 600 | { |
| 601 | m_Res = false; |
| 602 | break; |
| 603 | } |
| 604 | } |
| 605 | } |
| 606 | }; |
| 607 | |
| 608 | // Function is supported |
| 609 | supported &= CheckSupportRule(ActivationFunctionSupported(descriptor), reasonIfUnsupported, |
| 610 | "Reference activation: function not supported."); |
| 611 | |
| 612 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | bool RefLayerSupport::IsAdditionSupported(const TensorInfo& input0, |
| 616 | const TensorInfo& input1, |
| 617 | const TensorInfo& output, |
| 618 | Optional<std::string&> reasonIfUnsupported) const |
| 619 | { |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 620 | bool supported = true; |
| 621 | |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 622 | std::array<DataType,7> supportedTypes = { |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 623 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 624 | DataType::Float16, |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 625 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 626 | DataType::QAsymmU8, |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 627 | DataType::QSymmS16, |
| 628 | DataType::Signed32 |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 629 | }; |
| 630 | |
| 631 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 632 | "Reference addition: input 0 is not a supported type."); |
| 633 | |
| 634 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 635 | "Reference addition: input 1 is not a supported type."); |
| 636 | |
| 637 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 638 | "Reference addition: output is not a supported type."); |
| 639 | |
| 640 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 641 | "Reference addition: input 0 and Input 1 types are mismatched"); |
| 642 | |
| 643 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 644 | "Reference addition: input and output types are mismatched"); |
| 645 | |
| 646 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 647 | "Reference addition: shapes are not suitable for implicit broadcast."); |
| 648 | |
| 649 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 650 | } |
| 651 | |
Nikhil Raj | 68c2c90 | 2019-09-19 11:21:11 +0100 | [diff] [blame] | 652 | bool RefLayerSupport::IsArgMinMaxSupported(const armnn::TensorInfo &input, const armnn::TensorInfo &output, |
| 653 | const armnn::ArgMinMaxDescriptor &descriptor, |
| 654 | armnn::Optional<std::string &> reasonIfUnsupported) const |
| 655 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 656 | IgnoreUnused(descriptor); |
Nikhil Raj | 68c2c90 | 2019-09-19 11:21:11 +0100 | [diff] [blame] | 657 | |
Mike Kelly | 1f140f7 | 2021-04-06 12:25:55 +0100 | [diff] [blame] | 658 | std::array<DataType, 8> supportedInputTypes = |
Nikhil Raj | 68c2c90 | 2019-09-19 11:21:11 +0100 | [diff] [blame] | 659 | { |
Teresa Charlin | e300b36 | 2020-05-25 10:01:03 +0100 | [diff] [blame] | 660 | DataType::Float16, |
Nikhil Raj | 68c2c90 | 2019-09-19 11:21:11 +0100 | [diff] [blame] | 661 | DataType::Float32, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 662 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 663 | DataType::QAsymmU8, |
| 664 | DataType::QSymmS16, |
Mike Kelly | 1f140f7 | 2021-04-06 12:25:55 +0100 | [diff] [blame] | 665 | DataType::Signed32, |
| 666 | DataType::Signed64 |
| 667 | }; |
| 668 | |
| 669 | std::array<DataType,2> supportedOutputTypes = { |
| 670 | DataType::Signed32, |
| 671 | DataType::Signed64 |
Nikhil Raj | 68c2c90 | 2019-09-19 11:21:11 +0100 | [diff] [blame] | 672 | }; |
| 673 | |
| 674 | bool supported = true; |
| 675 | |
Mike Kelly | 1f140f7 | 2021-04-06 12:25:55 +0100 | [diff] [blame] | 676 | supported &= CheckSupportRule(TypeAnyOf(input, supportedInputTypes), reasonIfUnsupported, |
Nikhil Raj | 68c2c90 | 2019-09-19 11:21:11 +0100 | [diff] [blame] | 677 | "Reference ArgMinMax: input is not a supported type."); |
Mike Kelly | 1f140f7 | 2021-04-06 12:25:55 +0100 | [diff] [blame] | 678 | supported &= CheckSupportRule(TypeAnyOf(output, supportedOutputTypes), reasonIfUnsupported, |
Nikhil Raj | 68c2c90 | 2019-09-19 11:21:11 +0100 | [diff] [blame] | 679 | "Reference ArgMinMax: output type not supported"); |
| 680 | |
| 681 | return supported; |
| 682 | } |
| 683 | |
Samuel Yap | 6b47809 | 2022-07-06 15:36:03 +0100 | [diff] [blame] | 684 | bool RefLayerSupport::IsBatchMatMulSupported(const TensorInfo& inputX, |
| 685 | const TensorInfo& inputY, |
| 686 | const TensorInfo& output, |
| 687 | const BatchMatMulDescriptor& descriptor, |
| 688 | Optional<std::string &> reasonIfUnsupported) const |
| 689 | { |
| 690 | IgnoreUnused(descriptor); |
| 691 | |
| 692 | std::array<DataType, 6> supportedTypes = |
| 693 | { |
Samuel Yap | 6b47809 | 2022-07-06 15:36:03 +0100 | [diff] [blame] | 694 | DataType::Float16, |
| 695 | DataType::Float32, |
| 696 | DataType::QAsymmS8, |
| 697 | DataType::QAsymmU8, |
| 698 | DataType::QSymmS16 |
| 699 | }; |
| 700 | |
| 701 | bool supported = true; |
| 702 | |
| 703 | supported &= CheckSupportRule(TypeAnyOf(inputX, supportedTypes), reasonIfUnsupported, |
| 704 | "Reference batch matrix multiplication: input X is not a supported type"); |
| 705 | |
| 706 | supported &= CheckSupportRule(TypeAnyOf(inputY, supportedTypes), reasonIfUnsupported, |
| 707 | "Reference batch matrix multiplication: input Y is not a supported type"); |
| 708 | |
| 709 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 710 | "Reference batch matrix multiplication: output is not a supported type"); |
| 711 | |
| 712 | supported &= CheckSupportRule(TypesAreEqual(inputX, inputY), reasonIfUnsupported, |
| 713 | "Reference batch matrix multiplication: input X and input Y types are mismatched"); |
| 714 | |
| 715 | supported &= CheckSupportRule(TypesAreEqual(inputX, output), reasonIfUnsupported, |
| 716 | "Reference batch matrix multiplication: inputs and output types are mismatched"); |
| 717 | |
| 718 | supported &= CheckSupportRule(TensorNumDimensionsAreGreaterOrEqualTo(inputX, 2), |
| 719 | reasonIfUnsupported, |
| 720 | "Reference batch matrix multiplication: input X is not of rank 2 or greater"); |
| 721 | |
| 722 | supported &= CheckSupportRule(TensorNumDimensionsAreGreaterOrEqualTo(inputY, 2), |
| 723 | reasonIfUnsupported, |
| 724 | "Reference batch matrix multiplication: input Y is not of rank 2 or greater"); |
| 725 | |
| 726 | return supported; |
| 727 | } |
| 728 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 729 | bool RefLayerSupport::IsBatchNormalizationSupported(const TensorInfo& input, |
| 730 | const TensorInfo& output, |
| 731 | const TensorInfo& mean, |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 732 | const TensorInfo& variance, |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 733 | const TensorInfo& beta, |
| 734 | const TensorInfo& gamma, |
| 735 | const BatchNormalizationDescriptor& descriptor, |
| 736 | Optional<std::string&> reasonIfUnsupported) const |
| 737 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 738 | IgnoreUnused(descriptor); |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 739 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 740 | std::array<DataType, 6> supportedTypes = |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 741 | { |
| 742 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 743 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 744 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 745 | DataType::QAsymmU8, |
| 746 | DataType::QSymmS16 |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 747 | }; |
| 748 | |
| 749 | bool supported = true; |
| 750 | |
| 751 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 752 | "Reference batch normalization: input is not a supported type."); |
| 753 | |
| 754 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 755 | "Reference batch normalization: output is not a supported type."); |
| 756 | |
| 757 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 758 | "Reference batch normalization: input and output types are mismatched"); |
| 759 | |
| 760 | supported &= CheckSupportRule(TypeAnyOf(mean, supportedTypes), reasonIfUnsupported, |
| 761 | "Reference batch normalization: mean is not a supported type."); |
| 762 | |
| 763 | supported &= CheckSupportRule(TypeAnyOf(variance, supportedTypes), reasonIfUnsupported, |
| 764 | "Reference batch normalization: variance is not a supported type."); |
| 765 | |
| 766 | supported &= CheckSupportRule(TypeAnyOf(beta, supportedTypes), reasonIfUnsupported, |
| 767 | "Reference batch normalization: beta is not a supported type."); |
| 768 | |
| 769 | supported &= CheckSupportRule(TypeAnyOf(gamma, supportedTypes), reasonIfUnsupported, |
| 770 | "Reference batch normalization: gamma is not a supported type."); |
| 771 | |
| 772 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 773 | } |
| 774 | |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 775 | bool RefLayerSupport::IsBatchToSpaceNdSupported(const TensorInfo& input, |
| 776 | const TensorInfo& output, |
| 777 | const BatchToSpaceNdDescriptor& descriptor, |
| 778 | Optional<std::string&> reasonIfUnsupported) const |
| 779 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 780 | IgnoreUnused(descriptor); |
Francis Murtagh | d0dfe17 | 2019-06-25 10:57:10 +0100 | [diff] [blame] | 781 | |
| 782 | bool supported = true; |
| 783 | |
| 784 | std::string batchToSpaceNdLayerStr = "batchToSpaceNd"; |
| 785 | std::string inputTensorStr = "input"; |
| 786 | std::string outputTensorStr = "output"; |
| 787 | |
| 788 | // Define supported types. |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 789 | std::array<DataType,6> supportedTypes = |
Francis Murtagh | d0dfe17 | 2019-06-25 10:57:10 +0100 | [diff] [blame] | 790 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 791 | DataType::Float32, |
| 792 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 793 | DataType::QAsymmS8, |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 794 | DataType::QAsymmU8, |
| 795 | DataType::QSymmS16 |
Francis Murtagh | d0dfe17 | 2019-06-25 10:57:10 +0100 | [diff] [blame] | 796 | }; |
| 797 | |
| 798 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 799 | "Reference BatchToSpaceNd: input type not supported."); |
| 800 | |
| 801 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 802 | "Reference BatchToSpaceNd: output type not supported."); |
| 803 | |
| 804 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 805 | "Reference BatchToSpaceNd: input and output types mismatched."); |
| 806 | |
Francis Murtagh | d0dfe17 | 2019-06-25 10:57:10 +0100 | [diff] [blame] | 807 | return supported; |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 808 | } |
| 809 | |
mathad01 | b392e98 | 2021-04-07 12:07:30 +0100 | [diff] [blame] | 810 | bool RefLayerSupport::IsCastSupported(const TensorInfo& input, |
| 811 | const TensorInfo& output, |
| 812 | Optional<std::string&> reasonIfUnsupported) const |
| 813 | { |
| 814 | std::array<DataType, 9> supportedInputTypes = |
| 815 | { |
mathad01 | b392e98 | 2021-04-07 12:07:30 +0100 | [diff] [blame] | 816 | DataType::Float32, |
| 817 | DataType::Float16, |
| 818 | DataType::QSymmS8, |
| 819 | DataType::QAsymmS8, |
| 820 | DataType::QAsymmU8, |
| 821 | DataType::QSymmS16, |
| 822 | DataType::Signed32 |
| 823 | }; |
| 824 | |
| 825 | bool supported = true; |
| 826 | supported &= CheckSupportRule(TypeAnyOf(input, supportedInputTypes), reasonIfUnsupported, |
| 827 | "Reference cast: input is not a supported type"); |
| 828 | |
| 829 | |
| 830 | supported &= CheckSupportRule(TypeAnyOf(output, supportedInputTypes), reasonIfUnsupported, |
| 831 | "Reference cast: output is not a supported type"); |
| 832 | |
| 833 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 834 | "Reference cast: input and output shapes have different number of total elements"); |
| 835 | |
| 836 | return supported; |
| 837 | } |
| 838 | |
Simon Obute | 51f6777 | 2021-09-03 15:50:13 +0100 | [diff] [blame] | 839 | bool RefLayerSupport::IsChannelShuffleSupported(const TensorInfo& input, |
| 840 | const TensorInfo& output, |
| 841 | const ChannelShuffleDescriptor& descriptor, |
| 842 | Optional<std::string&> reasonIfUnsupported) const |
| 843 | { |
| 844 | IgnoreUnused(descriptor); |
| 845 | bool supported = true; |
| 846 | |
| 847 | // Define supported output and inputs types. |
| 848 | std::array<DataType, 7> supportedTypes = |
| 849 | { |
Simon Obute | 51f6777 | 2021-09-03 15:50:13 +0100 | [diff] [blame] | 850 | DataType::Float32, |
| 851 | DataType::Float16, |
| 852 | DataType::QAsymmS8, |
| 853 | DataType::QAsymmU8, |
| 854 | DataType::QSymmS8, |
| 855 | DataType::QSymmS16 |
| 856 | }; |
| 857 | |
| 858 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 859 | "Reference ChannelShuffle: input is not a supported type."); |
| 860 | |
| 861 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 862 | "Reference ChannelShuffle: output is not a supported type."); |
| 863 | |
| 864 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 865 | "Reference ChannelShuffle: input and output types are mismatched."); |
| 866 | |
| 867 | return supported; |
| 868 | } |
| 869 | |
| 870 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 871 | bool RefLayerSupport::IsComparisonSupported(const TensorInfo& input0, |
| 872 | const TensorInfo& input1, |
| 873 | const TensorInfo& output, |
| 874 | const ComparisonDescriptor& descriptor, |
| 875 | Optional<std::string&> reasonIfUnsupported) const |
| 876 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 877 | IgnoreUnused(descriptor); |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 878 | std::array<DataType, 8> supportedInputTypes = |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 879 | { |
Sadik Armagan | b60dd24 | 2020-03-19 13:53:16 +0000 | [diff] [blame] | 880 | DataType::Boolean, |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 881 | DataType::Float32, |
| 882 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 883 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 884 | DataType::QAsymmU8, |
Sadik Armagan | b60dd24 | 2020-03-19 13:53:16 +0000 | [diff] [blame] | 885 | DataType::QSymmS16, |
| 886 | DataType::Signed32 |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 887 | }; |
| 888 | |
| 889 | bool supported = true; |
| 890 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedInputTypes), reasonIfUnsupported, |
| 891 | "Reference comparison: input 0 is not a supported type"); |
| 892 | |
| 893 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 894 | "Reference comparison: input 0 and Input 1 types are mismatched"); |
| 895 | |
| 896 | supported &= CheckSupportRule(TypeIs(output, DataType::Boolean), reasonIfUnsupported, |
| 897 | "Reference comparison: output is not of type Boolean"); |
| 898 | |
| 899 | return supported; |
| 900 | } |
| 901 | |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 902 | bool RefLayerSupport::IsConcatSupported(const std::vector<const TensorInfo*> inputs, |
| 903 | const TensorInfo& output, |
Cathal Corbett | 34b429c | 2021-12-24 12:24:40 +0000 | [diff] [blame] | 904 | const OriginsDescriptor& descriptor, |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 905 | Optional<std::string&> reasonIfUnsupported) const |
| 906 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 907 | IgnoreUnused(descriptor); |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 908 | |
| 909 | bool supported = true; |
Teresa Charlin | 6abc7ee | 2022-02-22 17:32:27 +0000 | [diff] [blame] | 910 | std::array<DataType,7> supportedTypes = |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 911 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 912 | DataType::Float32, |
| 913 | DataType::Float16, |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 914 | DataType::QAsymmS8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 915 | DataType::QAsymmU8, |
Teresa Charlin | 6abc7ee | 2022-02-22 17:32:27 +0000 | [diff] [blame] | 916 | DataType::QSymmS16, |
| 917 | DataType::Signed32 |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 918 | }; |
| 919 | |
| 920 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 921 | "Reference concatenation: output type not supported"); |
| 922 | for (const TensorInfo* input : inputs) |
| 923 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 924 | ARMNN_ASSERT(input != nullptr); |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 925 | supported &= CheckSupportRule(TypeAnyOf(*input, supportedTypes), reasonIfUnsupported, |
| 926 | "Reference concatenation: input type not supported"); |
| 927 | |
| 928 | supported &= CheckSupportRule(TypesAreEqual(*input, output), reasonIfUnsupported, |
| 929 | "Reference concatenation: input and output types mismatched."); |
| 930 | } |
| 931 | |
| 932 | return supported; |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 933 | } |
| 934 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 935 | bool RefLayerSupport::IsConstantSupported(const TensorInfo& output, |
| 936 | Optional<std::string&> reasonIfUnsupported) const |
| 937 | { |
Teresa Charlin | 6fa8ce6 | 2020-05-25 16:16:44 +0100 | [diff] [blame] | 938 | std::array<DataType,8> supportedTypes = |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 939 | { |
Teresa Charlin | 6fa8ce6 | 2020-05-25 16:16:44 +0100 | [diff] [blame] | 940 | DataType::Float16, |
Nina Drozd | 58ef2c6 | 2019-05-16 12:09:18 +0100 | [diff] [blame] | 941 | DataType::Float32, |
Keith Davis | 67e6c54 | 2020-02-19 10:08:33 +0000 | [diff] [blame] | 942 | DataType::QAsymmS8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 943 | DataType::QAsymmU8, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 944 | DataType::QSymmS8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 945 | DataType::QSymmS16, |
| 946 | DataType::Signed32 |
Nina Drozd | 58ef2c6 | 2019-05-16 12:09:18 +0100 | [diff] [blame] | 947 | }; |
| 948 | |
| 949 | return CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 950 | "Reference constant: output is not a supported type."); |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 951 | } |
| 952 | |
| 953 | bool RefLayerSupport::IsConvertFp16ToFp32Supported(const TensorInfo& input, |
| 954 | const TensorInfo& output, |
| 955 | Optional<std::string&> reasonIfUnsupported) const |
| 956 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 957 | return (IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 958 | input.GetDataType(), |
| 959 | &TrueFunc<>, |
| 960 | &FalseInputFuncF32<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 961 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 962 | &FalseFuncI32<>, |
| 963 | &FalseFuncU8<>) && |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 964 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 965 | output.GetDataType(), |
| 966 | &FalseOutputFuncF16<>, |
| 967 | &TrueFunc<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 968 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 969 | &FalseFuncI32<>, |
| 970 | &FalseFuncU8<>)); |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 971 | } |
| 972 | |
| 973 | bool RefLayerSupport::IsConvertFp32ToFp16Supported(const TensorInfo& input, |
| 974 | const TensorInfo& output, |
| 975 | Optional<std::string&> reasonIfUnsupported) const |
| 976 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 977 | return (IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 978 | input.GetDataType(), |
| 979 | &FalseInputFuncF16<>, |
| 980 | &TrueFunc<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 981 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 982 | &FalseFuncI32<>, |
| 983 | &FalseFuncU8<>) && |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 984 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 985 | output.GetDataType(), |
| 986 | &TrueFunc<>, |
| 987 | &FalseOutputFuncF32<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 988 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 989 | &FalseFuncI32<>, |
| 990 | &FalseFuncU8<>)); |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 991 | } |
| 992 | |
| 993 | bool RefLayerSupport::IsConvolution2dSupported(const TensorInfo& input, |
| 994 | const TensorInfo& output, |
| 995 | const Convolution2dDescriptor& descriptor, |
| 996 | const TensorInfo& weights, |
| 997 | const Optional<TensorInfo>& biases, |
| 998 | Optional<std::string&> reasonIfUnsupported) const |
| 999 | { |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 1000 | bool supported = true; |
| 1001 | |
| 1002 | // Define supported types. |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1003 | std::array<DataType,7> supportedTypes = |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 1004 | { |
| 1005 | DataType::Float32, |
| 1006 | DataType::Float16, |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 1007 | DataType::QAsymmS8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1008 | DataType::QAsymmU8, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1009 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1010 | DataType::QSymmS16 |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 1011 | }; |
| 1012 | |
| 1013 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1014 | "Reference Convolution2d: input is not a supported type."); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 1015 | |
| 1016 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1017 | "Reference Convolution2d: output is not a supported type."); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 1018 | |
Ryan OShea | 3144159 | 2022-11-07 16:20:48 +0000 | [diff] [blame] | 1019 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1020 | "Reference Convolution2d: input and output types mismatched."); |
| 1021 | |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 1022 | |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 1023 | const DataType inputType = input.GetDataType(); |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 1024 | if (IsQuantized8BitType(inputType)) |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 1025 | { |
Jan Eilers | 1b2654f | 2021-09-24 15:45:46 +0100 | [diff] [blame] | 1026 | std::array<DataType, 3> supportedWeightTypes = |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 1027 | { |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1028 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1029 | DataType::QAsymmU8, |
Jan Eilers | 1b2654f | 2021-09-24 15:45:46 +0100 | [diff] [blame] | 1030 | DataType::QSymmS8 |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 1031 | }; |
| 1032 | |
| 1033 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedWeightTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1034 | "Reference Convolution2d: weights type not supported for quantized input."); |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 1035 | } |
| 1036 | else |
| 1037 | { |
| 1038 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1039 | "Reference Convolution2d: weights is not a supported type."); |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 1040 | |
| 1041 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1042 | "Reference Convolution2d: input and weights types mismatched."); |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 1043 | } |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 1044 | |
| 1045 | if (biases.has_value()) |
| 1046 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1047 | std::array<DataType,4> biasesSupportedTypes = |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 1048 | { |
| 1049 | DataType::Float32, |
| 1050 | DataType::Float16, |
| 1051 | DataType::Signed32 |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 1052 | }; |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 1053 | |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 1054 | supported &= CheckSupportRule(TypeAnyOf(biases.value(), biasesSupportedTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1055 | "Reference Convolution2d: biases is not a supported type."); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 1056 | } |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1057 | IgnoreUnused(descriptor); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 1058 | |
| 1059 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1060 | } |
| 1061 | |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 1062 | bool RefLayerSupport::IsConvolution3dSupported(const TensorInfo& input, |
| 1063 | const TensorInfo& output, |
| 1064 | const Convolution3dDescriptor& descriptor, |
| 1065 | const TensorInfo& weights, |
| 1066 | const Optional<TensorInfo>& biases, |
| 1067 | Optional<std::string&> reasonIfUnsupported) const |
| 1068 | { |
| 1069 | bool supported = true; |
| 1070 | |
| 1071 | // Define supported types. |
| 1072 | std::array<DataType,7> supportedTypes = |
| 1073 | { |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 1074 | DataType::Float32, |
| 1075 | DataType::Float16, |
| 1076 | DataType::QAsymmS8, |
| 1077 | DataType::QAsymmU8, |
| 1078 | DataType::QSymmS8, |
| 1079 | DataType::QSymmS16 |
| 1080 | }; |
| 1081 | |
| 1082 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1083 | "Reference Convolution3d: input is not a supported type."); |
| 1084 | |
| 1085 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1086 | "Reference Convolution3d: output is not a supported type."); |
| 1087 | |
| 1088 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1089 | "Reference Convolution3d: input and output types mismatched."); |
| 1090 | |
| 1091 | const DataType inputType = input.GetDataType(); |
| 1092 | if (IsQuantized8BitType(inputType)) |
| 1093 | { |
| 1094 | std::array<DataType, 3> supportedWeightTypes = |
| 1095 | { |
| 1096 | DataType::QAsymmS8, |
| 1097 | DataType::QAsymmU8, |
| 1098 | DataType::QSymmS8 |
| 1099 | }; |
| 1100 | |
| 1101 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedWeightTypes), reasonIfUnsupported, |
| 1102 | "Reference Convolution3d: weights type not supported for quantized input."); |
| 1103 | } |
| 1104 | else |
| 1105 | { |
| 1106 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 1107 | "Reference Convolution3d: weights is not a supported type."); |
| 1108 | |
| 1109 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 1110 | "Reference Convolution3d: input and weights types mismatched."); |
| 1111 | } |
| 1112 | |
| 1113 | if (biases.has_value()) |
| 1114 | { |
| 1115 | std::array<DataType,4> biasesSupportedTypes = |
| 1116 | { |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 1117 | DataType::Float32, |
| 1118 | DataType::Float16, |
| 1119 | DataType::Signed32 |
| 1120 | }; |
| 1121 | |
| 1122 | supported &= CheckSupportRule(TypeAnyOf(biases.value(), biasesSupportedTypes), reasonIfUnsupported, |
| 1123 | "Reference Convolution3d: biases is not a supported type."); |
| 1124 | } |
| 1125 | IgnoreUnused(descriptor); |
| 1126 | |
| 1127 | return supported; |
| 1128 | } |
| 1129 | |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 1130 | bool RefLayerSupport::IsDebugSupported(const TensorInfo& input, |
| 1131 | const TensorInfo& output, |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 1132 | Optional<std::string&> reasonIfUnsupported) const |
| 1133 | { |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 1134 | bool supported = true; |
| 1135 | |
Narumol Prangnawarat | 403a185 | 2020-03-12 14:24:13 +0000 | [diff] [blame] | 1136 | std::array<DataType, 8> supportedTypes = |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 1137 | { |
Narumol Prangnawarat | 403a185 | 2020-03-12 14:24:13 +0000 | [diff] [blame] | 1138 | DataType::BFloat16, |
Aron Virginas-Tar | db1a283 | 2019-11-12 16:15:11 +0000 | [diff] [blame] | 1139 | DataType::Float16, |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 1140 | DataType::Float32, |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 1141 | DataType::QAsymmS8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1142 | DataType::QAsymmU8, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1143 | DataType::QSymmS8, |
Narumol Prangnawarat | d2d917d | 2020-01-09 10:16:39 +0000 | [diff] [blame] | 1144 | DataType::QSymmS16, |
| 1145 | DataType::Signed32 |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 1146 | }; |
| 1147 | |
| 1148 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1149 | "Reference for Debug layer: input type not supported"); |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 1150 | |
| 1151 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1152 | "Reference for Debug layer: output type not supported"); |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 1153 | |
| 1154 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1155 | "Reference for Debug layer: input and output types are mismatched"); |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 1156 | |
| 1157 | return supported; |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 1158 | } |
| 1159 | |
Aron Virginas-Tar | 73f6642 | 2019-09-23 19:11:59 +0100 | [diff] [blame] | 1160 | bool RefLayerSupport::IsDepthToSpaceSupported(const TensorInfo& input, |
| 1161 | const TensorInfo& output, |
| 1162 | const DepthToSpaceDescriptor& descriptor, |
| 1163 | Optional<std::string&> reasonIfUnsupported) const |
| 1164 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1165 | IgnoreUnused(descriptor); |
Aron Virginas-Tar | 73f6642 | 2019-09-23 19:11:59 +0100 | [diff] [blame] | 1166 | bool supported = true; |
| 1167 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1168 | std::array<DataType,6> supportedTypes = |
Aron Virginas-Tar | 73f6642 | 2019-09-23 19:11:59 +0100 | [diff] [blame] | 1169 | { |
| 1170 | DataType::Float32, |
| 1171 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1172 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1173 | DataType::QAsymmU8, |
| 1174 | DataType::QSymmS16 |
Aron Virginas-Tar | 73f6642 | 2019-09-23 19:11:59 +0100 | [diff] [blame] | 1175 | }; |
| 1176 | |
| 1177 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1178 | "Reference DepthToSpace: input type not supported"); |
| 1179 | |
| 1180 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1181 | "Reference DepthToSpace: output type not supported"); |
| 1182 | |
| 1183 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1184 | "Reference DepthToSpace: input and output types are mismatched"); |
| 1185 | |
| 1186 | return supported; |
| 1187 | } |
| 1188 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1189 | bool RefLayerSupport::IsDepthwiseConvolutionSupported(const TensorInfo& input, |
| 1190 | const TensorInfo& output, |
| 1191 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 1192 | const TensorInfo& weights, |
| 1193 | const Optional<TensorInfo>& biases, |
| 1194 | Optional<std::string&> reasonIfUnsupported) const |
| 1195 | { |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1196 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1197 | bool supported = true; |
| 1198 | |
| 1199 | // Define supported types. |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1200 | std::array<DataType,7> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1201 | { |
| 1202 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1203 | DataType::Float16, |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 1204 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1205 | DataType::QAsymmU8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1206 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1207 | DataType::QSymmS16 |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1208 | }; |
| 1209 | |
| 1210 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1211 | "Reference DepthwiseConvolution2d: input is not a supported type."); |
| 1212 | |
| 1213 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1214 | "Reference DepthwiseConvolution2d: output is not a supported type."); |
| 1215 | |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1216 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1217 | "Reference DepthwiseConvolution2d: input and output types mismatched."); |
| 1218 | |
Teresa Charlin | d8df026 | 2019-11-11 12:28:15 +0000 | [diff] [blame] | 1219 | const DataType inputType = input.GetDataType(); |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 1220 | if (IsQuantized8BitType(inputType)) |
Teresa Charlin | d8df026 | 2019-11-11 12:28:15 +0000 | [diff] [blame] | 1221 | { |
Jan Eilers | 1b2654f | 2021-09-24 15:45:46 +0100 | [diff] [blame] | 1222 | std::array<DataType, 3> supportedWeightTypes = |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1223 | { |
| 1224 | DataType::QAsymmS8, |
| 1225 | DataType::QAsymmU8, |
| 1226 | DataType::QSymmS8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1227 | }; |
Teresa Charlin | d8df026 | 2019-11-11 12:28:15 +0000 | [diff] [blame] | 1228 | |
| 1229 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedWeightTypes), reasonIfUnsupported, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1230 | "Reference DepthwiseConvolution2d: weights type not supported for " |
| 1231 | "quantized input."); |
Teresa Charlin | d8df026 | 2019-11-11 12:28:15 +0000 | [diff] [blame] | 1232 | } |
| 1233 | else |
| 1234 | { |
| 1235 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 1236 | "Reference DepthwiseConvolution2d: weights is not a supported type."); |
| 1237 | |
| 1238 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 1239 | "Reference DepthwiseConvolution2d: input and weights types mismatched."); |
| 1240 | } |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1241 | |
| 1242 | if (biases.has_value()) |
| 1243 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1244 | std::array<DataType,4> biasesSupportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1245 | { |
| 1246 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1247 | DataType::Float16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1248 | DataType::Signed32 |
| 1249 | }; |
| 1250 | supported &= CheckSupportRule(TypeAnyOf(biases.value(), biasesSupportedTypes), reasonIfUnsupported, |
| 1251 | "Reference DepthwiseConvolution2d: biases is not a supported type."); |
| 1252 | } |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1253 | |
| 1254 | return supported; |
| 1255 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1256 | } |
| 1257 | |
Nattapat Chaimanowong | 8a54ac0 | 2019-03-29 15:25:04 +0000 | [diff] [blame] | 1258 | bool RefLayerSupport::IsDequantizeSupported(const TensorInfo& input, |
| 1259 | const TensorInfo& output, |
| 1260 | Optional<std::string&> reasonIfUnsupported) const |
| 1261 | { |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 1262 | bool supported = true; |
| 1263 | |
Keith Davis | b4dd5cc | 2022-04-07 11:32:00 +0100 | [diff] [blame] | 1264 | std::array<DataType,5> supportedInputTypes = { |
Ryan OShea | 9add120 | 2020-02-07 10:06:33 +0000 | [diff] [blame] | 1265 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1266 | DataType::QAsymmU8, |
Finn Williams | fd27106 | 2019-12-04 14:27:27 +0000 | [diff] [blame] | 1267 | DataType::QSymmS8, |
Keith Davis | b4dd5cc | 2022-04-07 11:32:00 +0100 | [diff] [blame] | 1268 | DataType::QSymmS16, |
| 1269 | DataType::Float16 |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 1270 | }; |
| 1271 | |
| 1272 | supported &= CheckSupportRule(TypeAnyOf(input, supportedInputTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1273 | "Reference for Dequantize layer: input type not supported."); |
| 1274 | |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 1275 | supported &= CheckSupportRule(TypeNotPerAxisQuantized(input), reasonIfUnsupported, |
Teresa Charlin | 1b1950d | 2021-06-02 20:23:21 +0100 | [diff] [blame] | 1276 | "Reference for Dequantize layer: per-axis quantized input not supported."); |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 1277 | |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1278 | std::array<DataType,3> supportedOutputTypes = { |
Jan Eilers | f710793 | 2019-11-01 11:09:36 +0000 | [diff] [blame] | 1279 | DataType::Float32, |
| 1280 | DataType::Float16 |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 1281 | }; |
| 1282 | |
| 1283 | supported &= CheckSupportRule(TypeAnyOf(output, supportedOutputTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1284 | "Reference for Dequantize layer: output type not supported."); |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 1285 | |
| 1286 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1287 | "Reference for Dequantize layer: input/output shapes have different num total " |
| 1288 | "elements."); |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 1289 | |
| 1290 | return supported; |
Nattapat Chaimanowong | 8a54ac0 | 2019-03-29 15:25:04 +0000 | [diff] [blame] | 1291 | } |
| 1292 | |
Derek Lamberti | 6a5e5e8 | 2019-12-05 14:41:20 +0000 | [diff] [blame] | 1293 | bool RefLayerSupport::IsDetectionPostProcessSupported(const TensorInfo& boxEncodings, |
| 1294 | const TensorInfo& scores, |
| 1295 | const TensorInfo& anchors, |
| 1296 | const TensorInfo& detectionBoxes, |
| 1297 | const TensorInfo& detectionClasses, |
| 1298 | const TensorInfo& detectionScores, |
| 1299 | const TensorInfo& numDetections, |
| 1300 | const DetectionPostProcessDescriptor& descriptor, |
| 1301 | Optional<std::string&> reasonIfUnsupported) const |
Narumol Prangnawarat | bc67cef | 2019-01-31 15:31:54 +0000 | [diff] [blame] | 1302 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1303 | IgnoreUnused(anchors, detectionBoxes, detectionClasses, detectionScores, numDetections, descriptor); |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 1304 | |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 1305 | bool supported = true; |
| 1306 | |
Sadik Armagan | aa41d5d | 2020-11-16 14:27:52 +0000 | [diff] [blame] | 1307 | std::array<DataType,6> supportedInputTypes = |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 1308 | { |
| 1309 | DataType::Float32, |
Sadik Armagan | aa41d5d | 2020-11-16 14:27:52 +0000 | [diff] [blame] | 1310 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1311 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1312 | DataType::QAsymmU8, |
| 1313 | DataType::QSymmS16 |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 1314 | }; |
| 1315 | |
Derek Lamberti | 6a5e5e8 | 2019-12-05 14:41:20 +0000 | [diff] [blame] | 1316 | supported &= CheckSupportRule(TypeAnyOf(boxEncodings, supportedInputTypes), reasonIfUnsupported, |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 1317 | "Reference DetectionPostProcess: input 0 is not a supported type."); |
| 1318 | |
Derek Lamberti | 6a5e5e8 | 2019-12-05 14:41:20 +0000 | [diff] [blame] | 1319 | supported &= CheckSupportRule(TypeAnyOf(scores, supportedInputTypes), reasonIfUnsupported, |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 1320 | "Reference DetectionPostProcess: input 1 is not a supported type."); |
| 1321 | |
| 1322 | return supported; |
Narumol Prangnawarat | bc67cef | 2019-01-31 15:31:54 +0000 | [diff] [blame] | 1323 | } |
| 1324 | |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 1325 | bool RefLayerSupport::IsDilatedDepthwiseConvolutionSupported(const TensorInfo& input, |
| 1326 | const TensorInfo& output, |
| 1327 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 1328 | const TensorInfo& weights, |
| 1329 | const Optional<TensorInfo>& biases, |
| 1330 | Optional<std::string&> reasonIfUnsupported) const |
| 1331 | { |
Aron Virginas-Tar | aece4ed | 2019-06-14 17:00:09 +0100 | [diff] [blame] | 1332 | return IsDepthwiseConvolutionSupported(input, output, descriptor, weights, biases, reasonIfUnsupported); |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 1333 | } |
| 1334 | |
Aron Virginas-Tar | aece4ed | 2019-06-14 17:00:09 +0100 | [diff] [blame] | 1335 | bool RefLayerSupport::IsDivisionSupported(const TensorInfo& input0, |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1336 | const TensorInfo& input1, |
| 1337 | const TensorInfo& output, |
| 1338 | Optional<std::string&> reasonIfUnsupported) const |
| 1339 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1340 | bool supported = true; |
| 1341 | |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 1342 | std::array<DataType,7> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1343 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1344 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1345 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1346 | DataType::QAsymmU8, |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 1347 | DataType::QSymmS16, |
| 1348 | DataType::Signed32 |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1349 | }; |
| 1350 | |
| 1351 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1352 | "Reference division: input 0 is not a supported type."); |
| 1353 | |
| 1354 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1355 | "Reference division: input 1 is not a supported type."); |
| 1356 | |
| 1357 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1358 | "Reference division: output is not a supported type."); |
| 1359 | |
| 1360 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1361 | "Reference division: input 0 and Input 1 types are mismatched"); |
| 1362 | |
| 1363 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1364 | "Reference division: input and output types are mismatched"); |
| 1365 | |
| 1366 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1367 | "Reference division: shapes are not suitable for implicit broadcast."); |
| 1368 | |
| 1369 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1370 | } |
| 1371 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 1372 | bool RefLayerSupport::IsElementwiseUnarySupported(const TensorInfo& input, |
| 1373 | const TensorInfo& output, |
| 1374 | const ElementwiseUnaryDescriptor& descriptor, |
| 1375 | Optional<std::string&> reasonIfUnsupported) const |
| 1376 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1377 | IgnoreUnused(descriptor); |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 1378 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1379 | std::array<DataType, 7> supportedTypes = |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 1380 | { |
| 1381 | DataType::Float32, |
| 1382 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1383 | DataType::QAsymmS8, |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 1384 | DataType::QAsymmU8, |
Sadik Armagan | ac47210 | 2020-03-24 09:54:36 +0000 | [diff] [blame] | 1385 | DataType::QSymmS16, |
| 1386 | DataType::Signed32 |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 1387 | }; |
| 1388 | |
Narumol Prangnawarat | 0c95f4c | 2020-11-18 16:52:07 +0000 | [diff] [blame] | 1389 | std::array<DataType, 1> logicalSupportedTypes = |
| 1390 | { |
| 1391 | DataType::Boolean |
| 1392 | }; |
| 1393 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 1394 | bool supported = true; |
| 1395 | |
Narumol Prangnawarat | 0c95f4c | 2020-11-18 16:52:07 +0000 | [diff] [blame] | 1396 | if (descriptor.m_Operation == UnaryOperation::LogicalNot) |
| 1397 | { |
| 1398 | supported &= CheckSupportRule(TypeAnyOf(input, logicalSupportedTypes), reasonIfUnsupported, |
| 1399 | "Reference elementwise unary: input type not supported"); |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 1400 | |
Narumol Prangnawarat | 0c95f4c | 2020-11-18 16:52:07 +0000 | [diff] [blame] | 1401 | supported &= CheckSupportRule(TypeAnyOf(output, logicalSupportedTypes), reasonIfUnsupported, |
| 1402 | "Reference elementwise unary: output type not supported"); |
| 1403 | } |
| 1404 | else |
| 1405 | { |
| 1406 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1407 | "Reference elementwise unary: input type not supported"); |
| 1408 | |
| 1409 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1410 | "Reference elementwise unary: output type not supported"); |
| 1411 | } |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 1412 | |
| 1413 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1414 | "Reference elementwise unary: input and output types not matching"); |
| 1415 | |
| 1416 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1417 | "Reference elementwise unary: input and output shapes" |
| 1418 | "have different number of total elements"); |
| 1419 | |
| 1420 | return supported; |
| 1421 | } |
| 1422 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1423 | bool RefLayerSupport::IsFakeQuantizationSupported(const TensorInfo& input, |
| 1424 | const FakeQuantizationDescriptor& descriptor, |
| 1425 | Optional<std::string&> reasonIfUnsupported) const |
| 1426 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1427 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1428 | bool supported = true; |
| 1429 | |
| 1430 | std::array<DataType,1> supportedTypes = |
| 1431 | { |
| 1432 | DataType::Float32 |
| 1433 | }; |
| 1434 | |
| 1435 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1436 | "Reference fake quantization: input type not supported."); |
| 1437 | |
| 1438 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1439 | } |
| 1440 | |
Ryan OShea | f4bfa6a | 2020-06-10 11:33:37 +0100 | [diff] [blame] | 1441 | bool RefLayerSupport::IsFillSupported(const TensorInfo& input, |
| 1442 | const TensorInfo& output, |
| 1443 | const FillDescriptor& descriptor, |
| 1444 | Optional<std::string&> reasonIfUnsupported) const |
| 1445 | { |
| 1446 | IgnoreUnused(descriptor); |
| 1447 | IgnoreUnused(output); |
| 1448 | |
| 1449 | bool supported = true; |
| 1450 | |
Sadik Armagan | a792a05 | 2020-06-23 16:22:23 +0100 | [diff] [blame] | 1451 | std::array<DataType,3> supportedTypes = |
Ryan OShea | f4bfa6a | 2020-06-10 11:33:37 +0100 | [diff] [blame] | 1452 | { |
| 1453 | DataType::Float32, |
Sadik Armagan | a792a05 | 2020-06-23 16:22:23 +0100 | [diff] [blame] | 1454 | DataType::Float16, |
| 1455 | DataType::Signed32 |
Ryan OShea | f4bfa6a | 2020-06-10 11:33:37 +0100 | [diff] [blame] | 1456 | }; |
| 1457 | |
Teresa Charlin | 4b10fef | 2020-07-29 09:36:41 +0100 | [diff] [blame] | 1458 | supported &= CheckSupportRule(TypeIs(input, DataType::Signed32), reasonIfUnsupported, |
Ryan OShea | f4bfa6a | 2020-06-10 11:33:37 +0100 | [diff] [blame] | 1459 | "Reference Fill: input type not supported."); |
| 1460 | |
Teresa Charlin | 4408850 | 2020-07-27 11:27:19 +0100 | [diff] [blame] | 1461 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1462 | "Reference Fill: output type not supported."); |
Ryan OShea | f4bfa6a | 2020-06-10 11:33:37 +0100 | [diff] [blame] | 1463 | return supported; |
| 1464 | } |
| 1465 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1466 | bool RefLayerSupport::IsFloorSupported(const TensorInfo& input, |
| 1467 | const TensorInfo& output, |
| 1468 | Optional<std::string&> reasonIfUnsupported) const |
| 1469 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1470 | IgnoreUnused(output); |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 1471 | bool supported = true; |
| 1472 | |
Teresa Charlin | 3a3a6bf | 2022-05-05 15:26:27 +0100 | [diff] [blame] | 1473 | std::array<DataType,3> supportedTypes = |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 1474 | { |
James Conroy | b40d710 | 2019-06-04 12:32:09 +0100 | [diff] [blame] | 1475 | DataType::Float32, |
Teresa Charlin | 3a3a6bf | 2022-05-05 15:26:27 +0100 | [diff] [blame] | 1476 | DataType::Float16 |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 1477 | }; |
| 1478 | |
| 1479 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1480 | "Reference Floor: input type not supported."); |
| 1481 | |
| 1482 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1483 | "Reference Floor: output type not supported."); |
| 1484 | |
| 1485 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1486 | } |
| 1487 | |
| 1488 | bool RefLayerSupport::IsFullyConnectedSupported(const TensorInfo& input, |
| 1489 | const TensorInfo& output, |
| 1490 | const TensorInfo& weights, |
| 1491 | const TensorInfo& biases, |
| 1492 | const FullyConnectedDescriptor& descriptor, |
| 1493 | Optional<std::string&> reasonIfUnsupported) const |
| 1494 | { |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1495 | bool supported = true; |
| 1496 | |
| 1497 | // Define supported types. |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1498 | std::array<DataType,6> supportedTypes = |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1499 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1500 | DataType::Float32, |
| 1501 | DataType::Float16, |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1502 | DataType::QAsymmS8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1503 | DataType::QAsymmU8, |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1504 | DataType::QSymmS16 |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1505 | }; |
| 1506 | |
| 1507 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1508 | "Reference Fully Connected: input type not supported."); |
| 1509 | |
| 1510 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1511 | "Reference Fully Connected: output type not supported."); |
| 1512 | |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1513 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 1514 | "Reference Fully Connected: weights type not supported."); |
| 1515 | |
Ryan OShea | 3144159 | 2022-11-07 16:20:48 +0000 | [diff] [blame] | 1516 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1517 | "Reference Fully Connected: input and output types mismatched."); |
Narumol Prangnawarat | 57ef008 | 2020-03-26 09:20:43 +0000 | [diff] [blame] | 1518 | |
Jan Eilers | 1f45dc3 | 2020-06-15 11:43:03 +0100 | [diff] [blame] | 1519 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 1520 | "Reference Fully Connected: weights is not a supported type."); |
Francis Murtagh | ddb1d06 | 2020-03-10 13:51:45 +0000 | [diff] [blame] | 1521 | |
Jan Eilers | 1f45dc3 | 2020-06-15 11:43:03 +0100 | [diff] [blame] | 1522 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 1523 | "Reference Fully Connected: input and weights types mismatched."); |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1524 | |
| 1525 | if (descriptor.m_BiasEnabled) |
| 1526 | { |
| 1527 | // Defined supported types for bias |
Sadik Armagan | db73c98 | 2020-04-01 17:35:30 +0100 | [diff] [blame] | 1528 | std::array<DataType, 5> |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1529 | supportedBiasTypes = |
| 1530 | { |
| 1531 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1532 | DataType::Float16, |
Sadik Armagan | db73c98 | 2020-04-01 17:35:30 +0100 | [diff] [blame] | 1533 | DataType::Signed32, |
| 1534 | DataType::QAsymmS8 |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1535 | }; |
| 1536 | |
| 1537 | supported &= CheckSupportRule(TypeAnyOf(biases, supportedBiasTypes), reasonIfUnsupported, |
| 1538 | "Reference Fully Connected: bias type not supported."); |
| 1539 | |
| 1540 | supported &= CheckSupportRule(BiasAndWeightsTypesMatch(biases, weights), reasonIfUnsupported, |
| 1541 | "Reference Fully Connected: bias and weight types mismatch."); |
| 1542 | |
| 1543 | supported &= CheckSupportRule(BiasAndWeightsTypesCompatible(weights, supportedBiasTypes), reasonIfUnsupported, |
| 1544 | "Reference Fully Connected: bias type inferred from weights is incompatible."); |
| 1545 | |
Narumol Prangnawarat | 366d723 | 2020-04-29 12:58:17 +0100 | [diff] [blame] | 1546 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(biases, 1U), reasonIfUnsupported, |
| 1547 | "Reference Fully Connected: bias must have 1 dimension."); |
| 1548 | |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1549 | } |
| 1550 | |
| 1551 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1552 | } |
| 1553 | |
Teresa Charlin | b2d3ec5 | 2022-04-12 22:07:09 +0100 | [diff] [blame] | 1554 | bool RefLayerSupport::IsGatherNdSupported(const armnn::TensorInfo& input0, |
| 1555 | const armnn::TensorInfo& input1, |
| 1556 | const armnn::TensorInfo& output, |
| 1557 | armnn::Optional<std::string&> reasonIfUnsupported) const |
| 1558 | { |
| 1559 | bool supported = true; |
| 1560 | std::array<DataType,7> supportedTypes = |
| 1561 | { |
Teresa Charlin | b2d3ec5 | 2022-04-12 22:07:09 +0100 | [diff] [blame] | 1562 | DataType::Float32, |
| 1563 | DataType::Float16, |
| 1564 | DataType::QAsymmS8, |
| 1565 | DataType::QAsymmU8, |
| 1566 | DataType::QSymmS16, |
| 1567 | DataType::Signed32 |
| 1568 | }; |
| 1569 | |
| 1570 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1571 | "Reference GatherNd: input type not supported"); |
| 1572 | |
| 1573 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1574 | "Reference GatherNd: output type not supported"); |
| 1575 | |
| 1576 | supported &= CheckSupportRule(TypeIs(input1, DataType::Signed32), reasonIfUnsupported, |
| 1577 | "Reference GatherNd: indices (input1) type not supported"); |
| 1578 | |
| 1579 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1580 | "Reference GatherNd: input and output types not matching"); |
| 1581 | |
| 1582 | return supported; |
| 1583 | } |
| 1584 | |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 1585 | bool RefLayerSupport::IsGatherSupported(const armnn::TensorInfo& input0, |
| 1586 | const armnn::TensorInfo& input1, |
| 1587 | const armnn::TensorInfo& output, |
Teresa Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 1588 | const GatherDescriptor& descriptor, |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 1589 | armnn::Optional<std::string&> reasonIfUnsupported) const |
| 1590 | { |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 1591 | bool supported = true; |
Teresa Charlin | 3940d8b | 2020-05-29 16:47:23 +0100 | [diff] [blame] | 1592 | std::array<DataType,7> supportedTypes = |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 1593 | { |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1594 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1595 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1596 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1597 | DataType::QAsymmU8, |
Teresa Charlin | 3940d8b | 2020-05-29 16:47:23 +0100 | [diff] [blame] | 1598 | DataType::QSymmS16, |
| 1599 | DataType::Signed32 |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 1600 | }; |
| 1601 | |
Nikhil Raj | 369d8fc | 2022-11-24 13:12:36 +0000 | [diff] [blame] | 1602 | IgnoreUnused(descriptor); |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 1603 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1604 | "Reference Gather: input type not supported"); |
| 1605 | |
| 1606 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1607 | "Reference Gather: output type not supported"); |
| 1608 | |
| 1609 | supported &= CheckSupportRule(TypeIs(input1, DataType::Signed32), reasonIfUnsupported, |
| 1610 | "Reference Gather: indices (input1) type not supported"); |
| 1611 | |
| 1612 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1613 | "Reference Gather: input and output types not matching"); |
| 1614 | |
| 1615 | return supported; |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 1616 | } |
| 1617 | |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 1618 | bool RefLayerSupport::IsInputSupported(const TensorInfo& /*input*/, |
| 1619 | Optional<std::string&> /*reasonIfUnsupported*/) const |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1620 | { |
Narumol Prangnawarat | b6441e4 | 2019-06-04 11:22:00 +0100 | [diff] [blame] | 1621 | return true; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1622 | } |
| 1623 | |
Kevin May | 09ca49c | 2019-10-09 12:37:34 +0100 | [diff] [blame] | 1624 | bool RefLayerSupport::IsInstanceNormalizationSupported(const TensorInfo& input, |
| 1625 | const TensorInfo& output, |
| 1626 | const InstanceNormalizationDescriptor& descriptor, |
| 1627 | Optional<std::string&> reasonIfUnsupported) const |
| 1628 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1629 | IgnoreUnused(descriptor); |
Kevin May | 09ca49c | 2019-10-09 12:37:34 +0100 | [diff] [blame] | 1630 | // Define supported types |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1631 | std::array<DataType, 3> supportedTypes = |
Kevin May | 09ca49c | 2019-10-09 12:37:34 +0100 | [diff] [blame] | 1632 | { |
| 1633 | DataType::Float32, |
| 1634 | DataType::Float16 |
| 1635 | }; |
| 1636 | |
| 1637 | bool supported = true; |
| 1638 | |
| 1639 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1640 | "Reference Instance Normalization: input type not supported."); |
| 1641 | |
| 1642 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1643 | "Reference Instance Normalization: output type not supported."); |
| 1644 | |
| 1645 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1646 | "Reference Instance Normalization: input and output types mismatched."); |
| 1647 | |
| 1648 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1649 | "Reference Instance Normalization: input and output shapes have different " |
| 1650 | "num total elements."); |
| 1651 | |
| 1652 | return supported; |
| 1653 | } |
| 1654 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1655 | bool RefLayerSupport::IsL2NormalizationSupported(const TensorInfo& input, |
| 1656 | const TensorInfo& output, |
| 1657 | const L2NormalizationDescriptor& descriptor, |
| 1658 | Optional<std::string&> reasonIfUnsupported) const |
| 1659 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1660 | IgnoreUnused(descriptor); |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 1661 | // Define supported types |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1662 | std::array<DataType, 6> supportedTypes = |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 1663 | { |
| 1664 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1665 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1666 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1667 | DataType::QAsymmU8, |
| 1668 | DataType::QSymmS16 |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 1669 | }; |
| 1670 | |
| 1671 | bool supported = true; |
| 1672 | |
| 1673 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1674 | "Reference L2normalization: input type not supported."); |
| 1675 | |
| 1676 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1677 | "Reference L2normalization: output type not supported."); |
| 1678 | |
| 1679 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1680 | "Reference L2normalization: input and output types mismatched."); |
| 1681 | |
| 1682 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1683 | "Reference L2normalization: input and output shapes have different " |
| 1684 | "num total elements."); |
| 1685 | |
| 1686 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1687 | } |
| 1688 | |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 1689 | bool RefLayerSupport::IsLogicalBinarySupported(const TensorInfo& input0, |
| 1690 | const TensorInfo& input1, |
| 1691 | const TensorInfo& output, |
| 1692 | const LogicalBinaryDescriptor& descriptor, |
| 1693 | Optional<std::string&> reasonIfUnsupported) const |
| 1694 | { |
| 1695 | IgnoreUnused(descriptor); |
| 1696 | |
| 1697 | std::array<DataType, 1> supportedTypes = |
| 1698 | { |
| 1699 | DataType::Boolean |
| 1700 | }; |
| 1701 | |
| 1702 | bool supported = true; |
| 1703 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1704 | "Reference LogicalBinary: input 0 type not supported"); |
| 1705 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1706 | "Reference LogicalBinary: input 1 type not supported"); |
| 1707 | |
| 1708 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1709 | "Reference LogicalBinary: input and output types do not match"); |
| 1710 | |
| 1711 | return supported; |
| 1712 | } |
| 1713 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1714 | bool RefLayerSupport::IsLogSoftmaxSupported(const TensorInfo& input, |
| 1715 | const TensorInfo& output, |
| 1716 | const LogSoftmaxDescriptor& descriptor, |
| 1717 | Optional<std::string&> reasonIfUnsupported) const |
| 1718 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1719 | IgnoreUnused(descriptor); |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1720 | |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1721 | std::array<DataType, 3> supportedTypes = |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1722 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1723 | DataType::Float32, |
| 1724 | DataType::Float16 |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1725 | }; |
| 1726 | |
| 1727 | bool supported = true; |
| 1728 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1729 | "Reference LogSoftmax: input type not supported"); |
| 1730 | |
| 1731 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1732 | "Reference LogSoftmax: output type not supported"); |
| 1733 | |
| 1734 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1735 | "Reference LogSoftmax: input and output types do not match"); |
| 1736 | |
| 1737 | return supported; |
| 1738 | } |
| 1739 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1740 | bool RefLayerSupport::IsLstmSupported(const TensorInfo& input, |
| 1741 | const TensorInfo& outputStateIn, |
| 1742 | const TensorInfo& cellStateIn, |
| 1743 | const TensorInfo& scratchBuffer, |
| 1744 | const TensorInfo& outputStateOut, |
| 1745 | const TensorInfo& cellStateOut, |
| 1746 | const TensorInfo& output, |
| 1747 | const LstmDescriptor& descriptor, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1748 | const LstmInputParamsInfo& paramsInfo, |
| 1749 | Optional<std::string&> reasonIfUnsupported) const |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1750 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1751 | IgnoreUnused(descriptor); |
| 1752 | IgnoreUnused(paramsInfo); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1753 | |
| 1754 | bool supported = true; |
| 1755 | |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1756 | std::array<DataType,3> supportedTypes = { |
Conor Kennedy | b9971c9 | 2019-05-07 07:14:23 +0100 | [diff] [blame] | 1757 | DataType::Float32, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1758 | DataType::QSymmS16 |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1759 | }; |
| 1760 | |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1761 | // check inputs and outputs |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1762 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1763 | "Reference Lstm: input is not a supported type."); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1764 | supported &= CheckSupportRule(TypesAreEqual(input, outputStateIn), reasonIfUnsupported, |
| 1765 | "Reference Lstm: input and outputStateIn types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1766 | supported &= CheckSupportRule(TypesAreEqual(input, cellStateIn), reasonIfUnsupported, |
| 1767 | "Reference Lstm: input and cellStateIn types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1768 | supported &= CheckSupportRule(TypesAreEqual(input, scratchBuffer), reasonIfUnsupported, |
| 1769 | "Reference Lstm: input and scratchBuffer types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1770 | supported &= CheckSupportRule(TypesAreEqual(input, outputStateOut), reasonIfUnsupported, |
| 1771 | "Reference Lstm: input and outputStateOut types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1772 | supported &= CheckSupportRule(TypesAreEqual(input, cellStateOut), reasonIfUnsupported, |
| 1773 | "Reference Lstm: input and cellStateOut types are mismatched"); |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 1774 | |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1775 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1776 | "Reference Lstm: input and output types are mismatched"); |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1777 | // check layer parameters |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1778 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToForgetWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1779 | "Reference Lstm: input and InputToForgetWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1780 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToCellWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1781 | "Reference Lstm: input and InputToCellWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1782 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToOutputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1783 | "Reference Lstm: input and InputToOutputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1784 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToForgetWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1785 | "Reference Lstm: input and RecurrentToForgetWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1786 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToCellWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1787 | "Reference Lstm: input and RecurrentToCellWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1788 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToOutputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1789 | "Reference Lstm: input and RecurrentToOutputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1790 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetForgetGateBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1791 | "Reference Lstm: input and ForgetGateBias types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1792 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1793 | "Reference Lstm: input and CellBias types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1794 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetOutputGateBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1795 | "Reference Lstm: input and OutputGateBias types are mismatched"); |
| 1796 | if (!descriptor.m_CifgEnabled) |
| 1797 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1798 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToInputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1799 | "Reference Lstm: input and InputToInputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1800 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToInputWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1801 | reasonIfUnsupported, |
| 1802 | "Reference Lstm: input and RecurrentToInputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1803 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputGateBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1804 | "Reference Lstm: input and InputGateBias types are mismatched"); |
| 1805 | if (descriptor.m_PeepholeEnabled) |
| 1806 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1807 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellToInputWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1808 | reasonIfUnsupported, |
| 1809 | "Reference Lstm: input and CellToInputWeights types are mismatched"); |
| 1810 | } |
| 1811 | } |
| 1812 | if (descriptor.m_PeepholeEnabled) |
| 1813 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1814 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellToForgetWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1815 | "Reference Lstm: input and CellToForgetWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1816 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellToOutputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1817 | "Reference Lstm: input and CellToOutputWeights types are mismatched"); |
| 1818 | } |
| 1819 | if (descriptor.m_ProjectionEnabled) |
| 1820 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1821 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetProjectionWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1822 | "Reference Lstm: input and mProjectionWeights types are mismatched"); |
| 1823 | if (paramsInfo.m_ProjectionBias != nullptr) |
| 1824 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1825 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetProjectionBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1826 | "Reference Lstm: input and ProjectionBias types are mismatched"); |
| 1827 | } |
| 1828 | } |
| 1829 | if (descriptor.m_LayerNormEnabled) |
| 1830 | { |
| 1831 | if (!descriptor.m_CifgEnabled) |
| 1832 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1833 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1834 | reasonIfUnsupported, |
| 1835 | "Reference Lstm: input and InputLayerNormWeights types are mismatched"); |
| 1836 | } |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1837 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetForgetLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1838 | reasonIfUnsupported, |
| 1839 | "Reference Lstm: input and ForgetLayerNormWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1840 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1841 | reasonIfUnsupported, |
| 1842 | "Reference Lstm: input and CellLayerNormWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1843 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetOutputLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1844 | reasonIfUnsupported, |
| 1845 | "Reference Lstm: input and OutputLayerNormWeights types are mismatched"); |
| 1846 | } |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1847 | |
| 1848 | return supported; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1849 | } |
| 1850 | |
saoste01 | 2df12b3 | 2018-11-28 16:57:20 +0000 | [diff] [blame] | 1851 | bool RefLayerSupport::IsMaximumSupported(const TensorInfo& input0, |
| 1852 | const TensorInfo& input1, |
| 1853 | const TensorInfo& output, |
| 1854 | Optional<std::string&> reasonIfUnsupported) const |
| 1855 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1856 | bool supported = true; |
| 1857 | |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 1858 | std::array<DataType,7> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1859 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1860 | DataType::Float16, |
Keith Davis | 67e6c54 | 2020-02-19 10:08:33 +0000 | [diff] [blame] | 1861 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1862 | DataType::QAsymmU8, |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 1863 | DataType::QSymmS16, |
| 1864 | DataType::Signed32 |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1865 | }; |
| 1866 | |
| 1867 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1868 | "Reference maximum: input 0 is not a supported type."); |
| 1869 | |
| 1870 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1871 | "Reference maximum: input 1 is not a supported type."); |
| 1872 | |
| 1873 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1874 | "Reference maximum: output is not a supported type."); |
| 1875 | |
| 1876 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1877 | "Reference maximum: input 0 and Input 1 types are mismatched"); |
| 1878 | |
| 1879 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1880 | "Reference maximum: input and output types are mismatched"); |
| 1881 | |
| 1882 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1883 | "Reference maximum: shapes are not suitable for implicit broadcast."); |
| 1884 | |
| 1885 | return supported; |
saoste01 | 2df12b3 | 2018-11-28 16:57:20 +0000 | [diff] [blame] | 1886 | } |
| 1887 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1888 | bool RefLayerSupport::IsMeanSupported(const TensorInfo& input, |
| 1889 | const TensorInfo& output, |
| 1890 | const MeanDescriptor& descriptor, |
| 1891 | Optional<std::string&> reasonIfUnsupported) const |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 1892 | { |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1893 | bool supported = true; |
| 1894 | std::string meanLayerStr = "Mean"; |
| 1895 | std::string outputTensorStr = "output"; |
| 1896 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1897 | std::array<DataType,6> supportedTypes = |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1898 | { |
| 1899 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1900 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1901 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1902 | DataType::QAsymmU8, |
| 1903 | DataType::QSymmS16 |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1904 | }; |
| 1905 | |
| 1906 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1907 | "Reference Mean: input type not supported."); |
| 1908 | |
| 1909 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1910 | "Reference Mean: input and output types are mismatched"); |
| 1911 | |
| 1912 | if (descriptor.m_KeepDims) |
| 1913 | { |
| 1914 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, input.GetNumDimensions()), |
| 1915 | reasonIfUnsupported, |
| 1916 | CreateIncorrectDimensionsErrorMsg(input.GetNumDimensions(), |
| 1917 | output.GetNumDimensions(), |
| 1918 | meanLayerStr, outputTensorStr).data()); |
| 1919 | } |
| 1920 | else if (descriptor.m_Axis.empty()) |
| 1921 | { |
| 1922 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, 1), |
| 1923 | reasonIfUnsupported, |
| 1924 | CreateIncorrectDimensionsErrorMsg(1, output.GetNumDimensions(), |
| 1925 | meanLayerStr, outputTensorStr).data()); |
| 1926 | } |
| 1927 | else |
| 1928 | { |
Matthew Sloyan | 171214c | 2020-09-09 09:07:37 +0100 | [diff] [blame] | 1929 | auto outputDim = input.GetNumDimensions() - armnn::numeric_cast<unsigned int>(descriptor.m_Axis.size()); |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1930 | |
| 1931 | if (outputDim > 0) |
| 1932 | { |
| 1933 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, outputDim), |
| 1934 | reasonIfUnsupported, |
| 1935 | CreateIncorrectDimensionsErrorMsg(outputDim, output.GetNumDimensions(), |
| 1936 | meanLayerStr, outputTensorStr).data()); |
| 1937 | } |
| 1938 | else |
| 1939 | { |
| 1940 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, 1), |
| 1941 | reasonIfUnsupported, |
| 1942 | CreateIncorrectDimensionsErrorMsg(1, output.GetNumDimensions(), |
| 1943 | meanLayerStr, outputTensorStr).data()); |
| 1944 | } |
| 1945 | } |
| 1946 | |
| 1947 | return supported; |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 1948 | } |
| 1949 | |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1950 | bool RefLayerSupport::IsMemCopySupported(const TensorInfo &input, |
| 1951 | const TensorInfo &output, |
| 1952 | Optional<std::string &> reasonIfUnsupported) const |
| 1953 | { |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1954 | bool supported = true; |
| 1955 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1956 | std::array<DataType,7> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1957 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1958 | DataType::BFloat16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1959 | DataType::Float32, |
| 1960 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1961 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1962 | DataType::QAsymmU8, |
| 1963 | DataType::QSymmS16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1964 | DataType::Boolean |
| 1965 | }; |
| 1966 | |
| 1967 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1968 | "Reference MemCopy: input type not supported"); |
| 1969 | |
| 1970 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1971 | "Reference MemCopy: output type not supported"); |
| 1972 | |
| 1973 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1974 | "Reference MemCopy: input and output types are mismatched"); |
| 1975 | |
| 1976 | return supported; |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1977 | } |
| 1978 | |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 1979 | bool RefLayerSupport::IsMinimumSupported(const TensorInfo& input0, |
| 1980 | const TensorInfo& input1, |
| 1981 | const TensorInfo& output, |
| 1982 | Optional<std::string&> reasonIfUnsupported) const |
| 1983 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1984 | bool supported = true; |
| 1985 | |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 1986 | std::array<DataType,7> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1987 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1988 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1989 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1990 | DataType::QAsymmU8, |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 1991 | DataType::QSymmS16, |
| 1992 | DataType::Signed32 |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1993 | }; |
| 1994 | |
| 1995 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1996 | "Reference minimum: input 0 is not a supported type."); |
| 1997 | |
| 1998 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1999 | "Reference minimum: input 1 is not a supported type."); |
| 2000 | |
| 2001 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2002 | "Reference minimum: output is not a supported type."); |
| 2003 | |
| 2004 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 2005 | "Reference minimum: input 0 and Input 1 types are mismatched"); |
| 2006 | |
| 2007 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 2008 | "Reference minimum: input and output types are mismatched"); |
| 2009 | |
| 2010 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 2011 | "Reference minimum: shapes are not suitable for implicit broadcast."); |
| 2012 | |
| 2013 | return supported; |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 2014 | } |
| 2015 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2016 | bool RefLayerSupport::IsMultiplicationSupported(const TensorInfo& input0, |
| 2017 | const TensorInfo& input1, |
| 2018 | const TensorInfo& output, |
| 2019 | Optional<std::string&> reasonIfUnsupported) const |
| 2020 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 2021 | bool supported = true; |
| 2022 | |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 2023 | std::array<DataType,7> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 2024 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 2025 | DataType::Float16, |
Keith Davis | 67e6c54 | 2020-02-19 10:08:33 +0000 | [diff] [blame] | 2026 | DataType::QAsymmS8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2027 | DataType::QAsymmU8, |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 2028 | DataType::QSymmS16, |
| 2029 | DataType::Signed32 |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 2030 | }; |
| 2031 | |
| 2032 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 2033 | "Reference multiplication: input 0 is not a supported type."); |
| 2034 | |
| 2035 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 2036 | "Reference multiplication: input 1 is not a supported type."); |
| 2037 | |
| 2038 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2039 | "Reference multiplication: output is not a supported type."); |
| 2040 | |
| 2041 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 2042 | "Reference multiplication: input 0 and Input 1 types are mismatched"); |
| 2043 | |
| 2044 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 2045 | "Reference multiplication: input and output types are mismatched"); |
| 2046 | |
| 2047 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 2048 | "Reference multiplication: shapes are not suitable for implicit broadcast."); |
| 2049 | |
| 2050 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2051 | } |
| 2052 | |
| 2053 | bool RefLayerSupport::IsNormalizationSupported(const TensorInfo& input, |
| 2054 | const TensorInfo& output, |
| 2055 | const NormalizationDescriptor& descriptor, |
| 2056 | Optional<std::string&> reasonIfUnsupported) const |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 2057 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2058 | IgnoreUnused(descriptor); |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 2059 | |
| 2060 | // Define supported types |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2061 | std::array<DataType, 6> supportedTypes = |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 2062 | { |
| 2063 | DataType::Float16, |
| 2064 | DataType::Float32, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2065 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2066 | DataType::QAsymmU8, |
| 2067 | DataType::QSymmS16 |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 2068 | }; |
| 2069 | |
| 2070 | bool supported = true; |
| 2071 | |
| 2072 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2073 | "Reference normalization: input type not supported."); |
| 2074 | |
| 2075 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2076 | "Reference normalization: output type not supported."); |
| 2077 | |
| 2078 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 2079 | "Reference normalization: input and output shapes have different " |
| 2080 | "num total elements."); |
| 2081 | |
| 2082 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2083 | } |
| 2084 | |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 2085 | bool RefLayerSupport::IsOutputSupported(const TensorInfo& /*output*/, |
| 2086 | Optional<std::string&> /*reasonIfUnsupported*/) const |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2087 | { |
Narumol Prangnawarat | b6441e4 | 2019-06-04 11:22:00 +0100 | [diff] [blame] | 2088 | return true; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2089 | } |
| 2090 | |
| 2091 | bool RefLayerSupport::IsPadSupported(const TensorInfo& input, |
| 2092 | const TensorInfo& output, |
| 2093 | const PadDescriptor& descriptor, |
| 2094 | Optional<std::string&> reasonIfUnsupported) const |
| 2095 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2096 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 2097 | bool supported = true; |
| 2098 | |
| 2099 | // Define supported output and inputs types. |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2100 | std::array<DataType,6> supportedTypes = |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 2101 | { |
| 2102 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 2103 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2104 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2105 | DataType::QAsymmU8, |
| 2106 | DataType::QSymmS16 |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 2107 | }; |
| 2108 | |
| 2109 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2110 | "Reference pad: input is not a supported type."); |
| 2111 | |
| 2112 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2113 | "Reference pad: output is not a supported type."); |
| 2114 | |
| 2115 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2116 | "Reference pad: input and output types are mismatched."); |
| 2117 | |
| 2118 | return supported; |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 2119 | } |
| 2120 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2121 | bool RefLayerSupport::IsPermuteSupported(const TensorInfo& input, |
| 2122 | const TensorInfo& output, |
| 2123 | const PermuteDescriptor& descriptor, |
| 2124 | Optional<std::string&> reasonIfUnsupported) const |
| 2125 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2126 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 2127 | bool supported = true; |
| 2128 | |
| 2129 | // Define supported output and inputs types. |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2130 | std::array<DataType, 6> supportedTypes = |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 2131 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2132 | DataType::BFloat16, |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 2133 | DataType::Float32, |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 2134 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2135 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2136 | DataType::QAsymmU8, |
| 2137 | DataType::QSymmS16 |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 2138 | }; |
| 2139 | |
| 2140 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2141 | "Reference permute: input is not a supported type."); |
| 2142 | |
| 2143 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2144 | "Reference permute: output is not a supported type."); |
| 2145 | |
| 2146 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2147 | "Reference permute: input and output types are mismatched."); |
| 2148 | |
| 2149 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2150 | } |
| 2151 | |
| 2152 | bool RefLayerSupport::IsPooling2dSupported(const TensorInfo& input, |
| 2153 | const TensorInfo& output, |
| 2154 | const Pooling2dDescriptor& descriptor, |
| 2155 | Optional<std::string&> reasonIfUnsupported) const |
| 2156 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2157 | IgnoreUnused(descriptor); |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 2158 | bool supported = true; |
| 2159 | |
| 2160 | // Define supported output and inputs types. |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2161 | std::array<DataType,6> supportedTypes = |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 2162 | { |
| 2163 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 2164 | DataType::Float16, |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 2165 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2166 | DataType::QAsymmU8, |
| 2167 | DataType::QSymmS16 |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 2168 | }; |
| 2169 | |
| 2170 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2171 | "Reference poolind2d: input is not a supported type."); |
| 2172 | |
| 2173 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2174 | "Reference poolind2d: output is not a supported type."); |
| 2175 | |
| 2176 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2177 | "Reference poolind2d: input and output types are mismatched."); |
| 2178 | |
| 2179 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2180 | } |
| 2181 | |
Tamás Nyíri | 7b885b3 | 2021-10-26 14:47:57 +0100 | [diff] [blame] | 2182 | bool RefLayerSupport::IsPooling3dSupported(const TensorInfo& input, |
| 2183 | const TensorInfo& output, |
| 2184 | const Pooling3dDescriptor& descriptor, |
| 2185 | Optional<std::string&> reasonIfUnsupported) const |
| 2186 | { |
| 2187 | IgnoreUnused(descriptor); |
| 2188 | bool supported = true; |
| 2189 | |
| 2190 | // Define supported output and inputs types. |
| 2191 | std::array<DataType,6> supportedTypes = |
| 2192 | { |
Tamás Nyíri | 7b885b3 | 2021-10-26 14:47:57 +0100 | [diff] [blame] | 2193 | DataType::Float32, |
| 2194 | DataType::Float16, |
| 2195 | DataType::QAsymmS8, |
| 2196 | DataType::QAsymmU8, |
| 2197 | DataType::QSymmS16 |
| 2198 | }; |
| 2199 | |
| 2200 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2201 | "Reference poolind3d: input is not a supported type."); |
| 2202 | |
| 2203 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2204 | "Reference poolind3d: output is not a supported type."); |
| 2205 | |
| 2206 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2207 | "Reference poolind3d: input and output types are mismatched."); |
| 2208 | |
| 2209 | return supported; |
| 2210 | } |
| 2211 | |
| 2212 | |
James Conroy | 4f1f899 | 2020-04-29 20:01:10 +0100 | [diff] [blame] | 2213 | bool RefLayerSupport::IsQLstmSupported(const TensorInfo& input, |
| 2214 | const TensorInfo& previousOutputIn, |
| 2215 | const TensorInfo& previousCellStateIn, |
| 2216 | const TensorInfo& outputStateOut, |
| 2217 | const TensorInfo& cellStateOut, |
| 2218 | const TensorInfo& output, |
| 2219 | const QLstmDescriptor& descriptor, |
| 2220 | const LstmInputParamsInfo& paramsInfo, |
| 2221 | Optional<std::string&> reasonIfUnsupported) const |
| 2222 | { |
| 2223 | IgnoreUnused(input); |
| 2224 | IgnoreUnused(previousOutputIn); |
| 2225 | IgnoreUnused(previousCellStateIn); |
| 2226 | IgnoreUnused(outputStateOut); |
| 2227 | IgnoreUnused(cellStateOut); |
| 2228 | IgnoreUnused(output); |
| 2229 | IgnoreUnused(descriptor); |
| 2230 | IgnoreUnused(paramsInfo); |
| 2231 | |
| 2232 | IgnoreUnused(reasonIfUnsupported); |
| 2233 | |
| 2234 | return true; |
| 2235 | } |
| 2236 | |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 2237 | bool RefLayerSupport::IsQuantizeSupported(const TensorInfo& input, |
| 2238 | const TensorInfo& output, |
| 2239 | Optional<std::string&> reasonIfUnsupported) const |
| 2240 | { |
| 2241 | bool supported = true; |
| 2242 | |
Finn Williams | fd27106 | 2019-12-04 14:27:27 +0000 | [diff] [blame] | 2243 | // Define supported input types. |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2244 | std::array<DataType,7> supportedInputTypes = { |
Keith Davis | 5e51cd8 | 2020-01-29 16:52:59 +0000 | [diff] [blame] | 2245 | DataType::Float32, |
Keith Davis | 3d8bc97 | 2020-02-04 09:31:47 +0000 | [diff] [blame] | 2246 | DataType::Float16, |
Ryan OShea | 9add120 | 2020-02-07 10:06:33 +0000 | [diff] [blame] | 2247 | DataType::QAsymmS8, |
Keith Davis | 5e51cd8 | 2020-01-29 16:52:59 +0000 | [diff] [blame] | 2248 | DataType::QAsymmU8, |
| 2249 | DataType::QSymmS8, |
| 2250 | DataType::QSymmS16 |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 2251 | }; |
| 2252 | |
| 2253 | supported &= CheckSupportRule(TypeAnyOf(input, supportedInputTypes), reasonIfUnsupported, |
| 2254 | "Reference quantize: input type not supported."); |
| 2255 | |
| 2256 | // Define supported output types. |
Ryan OShea | 9add120 | 2020-02-07 10:06:33 +0000 | [diff] [blame] | 2257 | std::array<DataType,4> supportedOutputTypes = { |
Ryan OShea | 9add120 | 2020-02-07 10:06:33 +0000 | [diff] [blame] | 2258 | DataType::QAsymmS8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2259 | DataType::QAsymmU8, |
Finn Williams | fd27106 | 2019-12-04 14:27:27 +0000 | [diff] [blame] | 2260 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2261 | DataType::QSymmS16 |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 2262 | }; |
| 2263 | supported &= CheckSupportRule(TypeAnyOf(output, supportedOutputTypes), reasonIfUnsupported, |
| 2264 | "Reference quantize: output type not supported."); |
| 2265 | |
| 2266 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 2267 | "Reference quantize: input and output shapes have different num total elements."); |
| 2268 | |
| 2269 | return supported; |
| 2270 | } |
| 2271 | |
Finn Williams | 2605b23 | 2020-06-10 15:53:46 +0100 | [diff] [blame] | 2272 | bool RefLayerSupport::IsRankSupported(const TensorInfo& input, |
| 2273 | const TensorInfo& output, |
| 2274 | Optional<std::string&> reasonIfUnsupported) const |
| 2275 | { |
| 2276 | IgnoreUnused(input); |
| 2277 | // Define supported output types. |
| 2278 | std::array<DataType,1> supportedOutputTypes = |
| 2279 | { |
| 2280 | DataType::Signed32, |
| 2281 | }; |
| 2282 | |
| 2283 | return CheckSupportRule(TypeAnyOf(output, supportedOutputTypes), reasonIfUnsupported, |
| 2284 | "Reference rank: input type not supported."); |
| 2285 | } |
| 2286 | |
Sadik Armagan | 0c3ea5b | 2021-02-03 09:29:30 +0000 | [diff] [blame] | 2287 | bool RefLayerSupport::IsReduceSupported(const TensorInfo& input, |
| 2288 | const TensorInfo& output, |
| 2289 | const ReduceDescriptor& descriptor, |
| 2290 | Optional<std::string&> reasonIfUnsupported) const |
| 2291 | { |
| 2292 | IgnoreUnused(descriptor); |
| 2293 | bool supported = true; |
| 2294 | std::array<DataType,7> supportedTypes = |
| 2295 | { |
Sadik Armagan | 0c3ea5b | 2021-02-03 09:29:30 +0000 | [diff] [blame] | 2296 | DataType::Float32, |
| 2297 | DataType::Float16, |
| 2298 | DataType::QAsymmS8, |
| 2299 | DataType::QAsymmU8, |
| 2300 | DataType::QSymmS16, |
| 2301 | DataType::Signed32 |
| 2302 | }; |
| 2303 | |
| 2304 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2305 | "Reference Reduce: input type not supported"); |
| 2306 | |
| 2307 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2308 | "Reference Reduce: output type not supported"); |
| 2309 | |
| 2310 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2311 | "Reference Reduce: input and output types not matching"); |
| 2312 | |
| 2313 | return supported; |
| 2314 | } |
| 2315 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2316 | bool RefLayerSupport::IsReshapeSupported(const TensorInfo& input, |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 2317 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 2318 | const ReshapeDescriptor& descriptor, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2319 | Optional<std::string&> reasonIfUnsupported) const |
| 2320 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2321 | IgnoreUnused(output); |
| 2322 | IgnoreUnused(descriptor); |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 2323 | // Define supported output types. |
Narumol Prangnawarat | 0c95f4c | 2020-11-18 16:52:07 +0000 | [diff] [blame] | 2324 | std::array<DataType,8> supportedOutputTypes = |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 2325 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2326 | DataType::BFloat16, |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 2327 | DataType::Float32, |
| 2328 | DataType::Float16, |
Narumol Prangnawarat | 0718ee9 | 2019-09-13 16:53:38 +0100 | [diff] [blame] | 2329 | DataType::Signed32, |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 2330 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2331 | DataType::QAsymmU8, |
Narumol Prangnawarat | 0c95f4c | 2020-11-18 16:52:07 +0000 | [diff] [blame] | 2332 | DataType::QSymmS16, |
| 2333 | DataType::Boolean |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 2334 | }; |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 2335 | |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 2336 | return CheckSupportRule(TypeAnyOf(input, supportedOutputTypes), reasonIfUnsupported, |
| 2337 | "Reference reshape: input type not supported."); |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2338 | } |
| 2339 | |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 2340 | bool RefLayerSupport::IsResizeSupported(const TensorInfo& input, |
| 2341 | const TensorInfo& output, |
| 2342 | const ResizeDescriptor& descriptor, |
| 2343 | Optional<std::string&> reasonIfUnsupported) const |
| 2344 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2345 | IgnoreUnused(descriptor); |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 2346 | bool supported = true; |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2347 | std::array<DataType,6> supportedTypes = |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 2348 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2349 | DataType::BFloat16, |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 2350 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 2351 | DataType::Float16, |
Keith Davis | 67e6c54 | 2020-02-19 10:08:33 +0000 | [diff] [blame] | 2352 | DataType::QAsymmS8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2353 | DataType::QAsymmU8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2354 | DataType::QSymmS16 |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 2355 | }; |
| 2356 | |
| 2357 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2358 | "Reference Resize: input type not supported"); |
| 2359 | |
| 2360 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2361 | "Reference Resize: output type not supported"); |
| 2362 | |
| 2363 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2364 | "Reference Resize: input and output types not matching"); |
| 2365 | |
| 2366 | return supported; |
| 2367 | } |
| 2368 | |
Tracy Narine | bb8d759 | 2023-07-13 16:50:54 +0100 | [diff] [blame] | 2369 | bool RefLayerSupport::IsReverseV2Supported(const TensorInfo& input0, |
| 2370 | const TensorInfo& input1, |
Tianle Cheng | 988354d | 2023-06-28 13:20:47 +0100 | [diff] [blame] | 2371 | const TensorInfo& output, |
Tianle Cheng | 988354d | 2023-06-28 13:20:47 +0100 | [diff] [blame] | 2372 | Optional<std::string&> reasonIfUnsupported) const |
| 2373 | { |
Tianle Cheng | 988354d | 2023-06-28 13:20:47 +0100 | [diff] [blame] | 2374 | bool supported = true; |
| 2375 | // ReverseV2 is data type agnostic so it can support all the types in the Reference backend |
Declan-ARM | 1bf56cd | 2023-07-20 17:32:57 +0100 | [diff] [blame] | 2376 | std::array<DataType,8> supportedTypes = |
Tianle Cheng | 988354d | 2023-06-28 13:20:47 +0100 | [diff] [blame] | 2377 | { |
| 2378 | DataType::BFloat16, |
| 2379 | DataType::Float32, |
| 2380 | DataType::Float16, |
| 2381 | DataType::QAsymmS8, |
| 2382 | DataType::QAsymmU8, |
Declan-ARM | 1bf56cd | 2023-07-20 17:32:57 +0100 | [diff] [blame] | 2383 | DataType::QSymmS8, |
| 2384 | DataType::QSymmS16, |
| 2385 | DataType::Signed32 |
Tianle Cheng | 988354d | 2023-06-28 13:20:47 +0100 | [diff] [blame] | 2386 | }; |
| 2387 | |
Tracy Narine | bb8d759 | 2023-07-13 16:50:54 +0100 | [diff] [blame] | 2388 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 2389 | "Reference ReverseV2: input0 type not supported"); |
Tianle Cheng | 988354d | 2023-06-28 13:20:47 +0100 | [diff] [blame] | 2390 | |
| 2391 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2392 | "Reference ReverseV2: output type not supported"); |
| 2393 | |
Tracy Narine | bb8d759 | 2023-07-13 16:50:54 +0100 | [diff] [blame] | 2394 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 2395 | "Reference ReverseV2: input0 and output types not matching"); |
| 2396 | |
| 2397 | std::array<DataType,6> input2SupportedTypes = |
| 2398 | { |
| 2399 | DataType::Signed32 |
| 2400 | }; |
| 2401 | |
| 2402 | supported &= CheckSupportRule(TypeAnyOf(input1, input2SupportedTypes), reasonIfUnsupported, |
| 2403 | "Reference ReverseV2: input1 type not supported"); |
Tianle Cheng | 988354d | 2023-06-28 13:20:47 +0100 | [diff] [blame] | 2404 | |
| 2405 | return supported; |
| 2406 | } |
| 2407 | |
Keith Davis | 3ae3f97 | 2021-05-21 16:33:48 +0100 | [diff] [blame] | 2408 | bool RefLayerSupport::IsShapeSupported(const TensorInfo& input, |
| 2409 | const TensorInfo& output, |
| 2410 | Optional<std::string&> reasonIfUnsupported) const |
| 2411 | { |
| 2412 | IgnoreUnused(input); |
| 2413 | bool supported = true; |
| 2414 | |
| 2415 | std::array<DataType, 1> supportedTypes = |
| 2416 | { |
| 2417 | DataType::Signed32 |
| 2418 | }; |
| 2419 | |
| 2420 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2421 | "Reference Shape: output type not supported"); |
| 2422 | |
| 2423 | return supported; |
| 2424 | } |
| 2425 | |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 2426 | bool RefLayerSupport::IsSliceSupported(const TensorInfo& input, |
| 2427 | const TensorInfo& output, |
| 2428 | const SliceDescriptor& descriptor, |
| 2429 | Optional<std::string&> reasonIfUnsupported) const |
| 2430 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2431 | IgnoreUnused(descriptor); |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 2432 | bool supported = true; |
| 2433 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2434 | std::array<DataType, 5> supportedTypes = |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 2435 | { |
| 2436 | DataType::Float32, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2437 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2438 | DataType::QAsymmU8, |
Ryan OShea | 980446b | 2023-06-08 16:23:28 +0100 | [diff] [blame] | 2439 | DataType::QSymmS16, |
| 2440 | DataType::Signed32 |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 2441 | }; |
| 2442 | |
| 2443 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2444 | "Reference Slice: input type not supported"); |
| 2445 | |
| 2446 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2447 | "Reference Slice: output type not supported"); |
| 2448 | |
| 2449 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2450 | "Reference Slice: input and output types are mismatched"); |
| 2451 | |
| 2452 | return supported; |
| 2453 | } |
| 2454 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2455 | bool RefLayerSupport::IsSoftmaxSupported(const TensorInfo& input, |
| 2456 | const TensorInfo& output, |
| 2457 | const SoftmaxDescriptor& descriptor, |
| 2458 | Optional<std::string&> reasonIfUnsupported) const |
| 2459 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2460 | IgnoreUnused(descriptor); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 2461 | bool supported = true; |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2462 | std::array<DataType,7> supportedTypes = |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 2463 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2464 | DataType::Float32, |
| 2465 | DataType::Float16, |
| 2466 | DataType::QSymmS8, |
| 2467 | DataType::QAsymmS8, |
| 2468 | DataType::QAsymmU8, |
| 2469 | DataType::QSymmS16 |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 2470 | }; |
| 2471 | |
| 2472 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 2473 | "Reference Softmax: output type not supported"); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 2474 | |
| 2475 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 2476 | "Reference Softmax: input type not supported"); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 2477 | |
| 2478 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 2479 | "Reference Softmax: input type not supported"); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 2480 | |
| 2481 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2482 | } |
| 2483 | |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 2484 | bool RefLayerSupport::IsSpaceToBatchNdSupported(const TensorInfo& input, |
| 2485 | const TensorInfo& output, |
| 2486 | const SpaceToBatchNdDescriptor& descriptor, |
| 2487 | Optional<std::string&> reasonIfUnsupported) const |
| 2488 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2489 | IgnoreUnused(descriptor); |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 2490 | bool supported = true; |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2491 | std::array<DataType,6> supportedTypes = |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 2492 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2493 | DataType::Float32, |
| 2494 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2495 | DataType::QAsymmS8, |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2496 | DataType::QAsymmU8, |
| 2497 | DataType::QSymmS16 |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 2498 | }; |
| 2499 | |
| 2500 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2501 | "Reference SpaceToBatchNd: input type not supported"); |
| 2502 | |
| 2503 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2504 | "Reference SpaceToBatchNd: output type not supported"); |
| 2505 | |
| 2506 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2507 | "Reference SpaceToBatchNd: input and output types are mismatched"); |
| 2508 | |
| 2509 | return supported; |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 2510 | } |
| 2511 | |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 2512 | bool RefLayerSupport::IsSpaceToDepthSupported(const TensorInfo& input, |
Keith Davis | 5191033 | 2019-06-26 15:28:43 +0100 | [diff] [blame] | 2513 | const TensorInfo& output, |
| 2514 | const SpaceToDepthDescriptor& descriptor, |
| 2515 | Optional<std::string&> reasonIfUnsupported) const |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 2516 | { |
| 2517 | |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2518 | IgnoreUnused(descriptor); |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 2519 | bool supported = true; |
| 2520 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2521 | std::array<DataType,6> supportedTypes = |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 2522 | { |
| 2523 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 2524 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2525 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2526 | DataType::QAsymmU8, |
| 2527 | DataType::QSymmS16 |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 2528 | }; |
| 2529 | |
| 2530 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2531 | "Reference SpaceToDepth: input type not supported"); |
| 2532 | |
| 2533 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2534 | "Reference SpaceToDepth: output type not supported"); |
| 2535 | |
| 2536 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2537 | "Reference SpaceToDepth: input and output types are mismatched"); |
| 2538 | |
| 2539 | return supported; |
| 2540 | } |
| 2541 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2542 | bool RefLayerSupport::IsSplitterSupported(const TensorInfo& input, |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 2543 | const std::vector<std::reference_wrapper<TensorInfo>>& outputs, |
| 2544 | const ViewsDescriptor& descriptor, |
| 2545 | Optional<std::string&> reasonIfUnsupported) const |
| 2546 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2547 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2548 | bool supported = true; |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2549 | std::array<DataType,6> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2550 | { |
| 2551 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 2552 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2553 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2554 | DataType::QAsymmU8, |
| 2555 | DataType::QSymmS16 |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2556 | }; |
| 2557 | |
| 2558 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2559 | "Reference splitter: output type not supported"); |
Derek Lamberti | eac4adb | 2020-08-25 13:05:59 +0100 | [diff] [blame] | 2560 | for (const TensorInfo& output : outputs) |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2561 | { |
| 2562 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2563 | "Reference splitter: input type not supported"); |
| 2564 | |
| 2565 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2566 | "Reference splitter: input and output types mismatched."); |
| 2567 | } |
| 2568 | |
| 2569 | return supported; |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 2570 | } |
| 2571 | |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 2572 | bool RefLayerSupport::IsStackSupported(const std::vector<const TensorInfo*>& inputs, |
| 2573 | const TensorInfo& output, |
| 2574 | const StackDescriptor& descriptor, |
| 2575 | Optional<std::string&> reasonIfUnsupported) const |
| 2576 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2577 | IgnoreUnused(descriptor); |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 2578 | |
| 2579 | bool supported = true; |
Sadik Armagan | 529195f | 2022-01-14 12:56:35 +0000 | [diff] [blame] | 2580 | std::array<DataType,7> supportedTypes = |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 2581 | { |
| 2582 | DataType::Float32, |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 2583 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2584 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2585 | DataType::QAsymmU8, |
Sadik Armagan | 529195f | 2022-01-14 12:56:35 +0000 | [diff] [blame] | 2586 | DataType::QSymmS16, |
| 2587 | DataType::Signed32 |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 2588 | }; |
| 2589 | |
| 2590 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2591 | "Reference stack: output type not supported"); |
| 2592 | for (const TensorInfo* input : inputs) |
| 2593 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 2594 | ARMNN_ASSERT(input != nullptr); |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 2595 | supported &= CheckSupportRule(TypeAnyOf(*input, supportedTypes), reasonIfUnsupported, |
| 2596 | "Reference stack: input type not supported"); |
| 2597 | |
| 2598 | supported &= CheckSupportRule(TypesAreEqual(*input, output), reasonIfUnsupported, |
| 2599 | "Reference stack: input and output types mismatched."); |
| 2600 | } |
| 2601 | |
| 2602 | return supported; |
| 2603 | } |
| 2604 | |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 2605 | bool RefLayerSupport::IsStridedSliceSupported(const TensorInfo& input, |
| 2606 | const TensorInfo& output, |
| 2607 | const StridedSliceDescriptor& descriptor, |
| 2608 | Optional<std::string&> reasonIfUnsupported) const |
| 2609 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2610 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2611 | bool supported = true; |
| 2612 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2613 | std::array<DataType,5> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2614 | { |
| 2615 | DataType::Float32, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2616 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2617 | DataType::QAsymmU8, |
| 2618 | DataType::QSymmS16 |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2619 | }; |
| 2620 | |
| 2621 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2622 | "Reference StridedSlice: input type not supported"); |
| 2623 | |
| 2624 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2625 | "Reference StridedSlice: output type not supported"); |
| 2626 | |
| 2627 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2628 | "Reference StridedSlice: input and output types are mismatched"); |
| 2629 | |
| 2630 | return supported; |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 2631 | } |
| 2632 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2633 | bool RefLayerSupport::IsSubtractionSupported(const TensorInfo& input0, |
| 2634 | const TensorInfo& input1, |
| 2635 | const TensorInfo& output, |
| 2636 | Optional<std::string&> reasonIfUnsupported) const |
| 2637 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 2638 | bool supported = true; |
| 2639 | |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 2640 | std::array<DataType,7> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 2641 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 2642 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2643 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2644 | DataType::QAsymmU8, |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 2645 | DataType::QSymmS16, |
| 2646 | DataType::Signed32 |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 2647 | }; |
| 2648 | |
| 2649 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 2650 | "Reference subtraction: input 0 is not a supported type."); |
| 2651 | |
| 2652 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 2653 | "Reference subtraction: input 1 is not a supported type."); |
| 2654 | |
| 2655 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2656 | "Reference subtraction: output is not a supported type."); |
| 2657 | |
| 2658 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 2659 | "Reference subtraction: input 0 and Input 1 types are mismatched"); |
| 2660 | |
| 2661 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 2662 | "Reference subtraction: input and output types are mismatched"); |
| 2663 | |
| 2664 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 2665 | "Reference subtraction: shapes are not suitable for implicit broadcast."); |
| 2666 | |
| 2667 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2668 | } |
| 2669 | |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 2670 | bool RefLayerSupport::IsPreluSupported(const TensorInfo& input, |
| 2671 | const TensorInfo& alpha, |
| 2672 | const TensorInfo& output, |
| 2673 | Optional<std::string&> reasonIfUnsupported) const |
| 2674 | { |
| 2675 | bool supported = true; |
| 2676 | |
Teresa Charlin | 3940d8b | 2020-05-29 16:47:23 +0100 | [diff] [blame] | 2677 | std::array<DataType, 6> supportedTypes |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 2678 | { |
| 2679 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 2680 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2681 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2682 | DataType::QAsymmU8, |
Teresa Charlin | 3940d8b | 2020-05-29 16:47:23 +0100 | [diff] [blame] | 2683 | DataType::QSymmS16 |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 2684 | }; |
| 2685 | |
| 2686 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2687 | "PReLU: input is not a supported type."); |
| 2688 | |
| 2689 | supported &= CheckSupportRule(TypeAnyOf(alpha, supportedTypes), reasonIfUnsupported, |
| 2690 | "PReLU: alpha is not a supported type."); |
| 2691 | |
| 2692 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2693 | "PReLU: output is not a supported type."); |
| 2694 | |
| 2695 | supported &= CheckSupportRule(TypesAreEqual(input, alpha, output), reasonIfUnsupported, |
| 2696 | "PReLU: input, alpha and output types are mismatched"); |
| 2697 | |
| 2698 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input, alpha, output), reasonIfUnsupported, |
| 2699 | "PReLU: shapes are not suitable for implicit broadcast"); |
| 2700 | |
| 2701 | return supported; |
| 2702 | } |
| 2703 | |
Teresa Charlin | 79a06a5 | 2023-07-13 17:16:45 +0100 | [diff] [blame] | 2704 | bool RefLayerSupport::IsTileSupported(const TensorInfo& input, |
| 2705 | const TensorInfo& output, |
| 2706 | const TileDescriptor& descriptor, |
| 2707 | Optional<std::string&> reasonIfUnsupported) const |
| 2708 | { |
| 2709 | IgnoreUnused(descriptor); |
| 2710 | |
| 2711 | bool supported = true; |
| 2712 | |
| 2713 | std::array<DataType, 7> supportedTypes |
| 2714 | { |
| 2715 | DataType::Float32, |
| 2716 | DataType::Float16, |
| 2717 | DataType::QAsymmS8, |
| 2718 | DataType::QAsymmU8, |
| 2719 | DataType::QSymmS8, |
| 2720 | DataType::QSymmS16, |
| 2721 | DataType::Signed32 |
| 2722 | }; |
| 2723 | |
| 2724 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2725 | "Tile: input type not supported."); |
| 2726 | |
| 2727 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2728 | "Tile: output type not supported"); |
| 2729 | |
| 2730 | return supported; |
| 2731 | } |
| 2732 | |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 2733 | bool RefLayerSupport::IsTransposeConvolution2dSupported(const TensorInfo& input, |
| 2734 | const TensorInfo& output, |
| 2735 | const TransposeConvolution2dDescriptor& descriptor, |
| 2736 | const TensorInfo& weights, |
| 2737 | const Optional<TensorInfo>& biases, |
| 2738 | Optional<std::string&> reasonIfUnsupported) const |
| 2739 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2740 | IgnoreUnused(descriptor); |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 2741 | bool supported = true; |
| 2742 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2743 | std::array<DataType,7> supportedTypes = |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 2744 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2745 | DataType::Float32, |
| 2746 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2747 | DataType::QAsymmS8, |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2748 | DataType::QAsymmU8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2749 | DataType::QSymmS8, |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2750 | DataType::QSymmS16 |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 2751 | }; |
| 2752 | |
| 2753 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2754 | "Reference TransposeConvolution2d: input is not a supported type."); |
| 2755 | |
| 2756 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2757 | "Reference TransposeConvolution2d: output is not a supported type."); |
| 2758 | |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 2759 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2760 | "Reference TransposeConvolution2d: input and output types mismatched."); |
| 2761 | |
Aron Virginas-Tar | 94d3b93 | 2019-11-11 12:54:47 +0000 | [diff] [blame] | 2762 | |
| 2763 | const DataType inputType = input.GetDataType(); |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2764 | if (IsQuantized8BitType(inputType)) |
Aron Virginas-Tar | 94d3b93 | 2019-11-11 12:54:47 +0000 | [diff] [blame] | 2765 | { |
Jan Eilers | 1b2654f | 2021-09-24 15:45:46 +0100 | [diff] [blame] | 2766 | std::array<DataType, 3> supportedWeightTypes = |
Aron Virginas-Tar | 94d3b93 | 2019-11-11 12:54:47 +0000 | [diff] [blame] | 2767 | { |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2768 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2769 | DataType::QAsymmU8, |
Jan Eilers | 1b2654f | 2021-09-24 15:45:46 +0100 | [diff] [blame] | 2770 | DataType::QSymmS8 |
Aron Virginas-Tar | 94d3b93 | 2019-11-11 12:54:47 +0000 | [diff] [blame] | 2771 | }; |
| 2772 | |
| 2773 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedWeightTypes), reasonIfUnsupported, |
| 2774 | "Reference TransposeConvolution2d: weights type not supported for " |
| 2775 | "quantized input."); |
| 2776 | } |
| 2777 | else |
| 2778 | { |
| 2779 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 2780 | "Reference TransposeConvolution2d: weights is not a supported type."); |
| 2781 | |
| 2782 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 2783 | "Reference TransposeConvolution2d: input and weights types mismatched."); |
| 2784 | } |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 2785 | |
| 2786 | if (biases.has_value()) |
| 2787 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2788 | std::array<DataType,4> biasesSupportedTypes = |
Aron Virginas-Tar | 651aafe | 2019-08-05 11:52:05 +0100 | [diff] [blame] | 2789 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2790 | DataType::Float32, |
| 2791 | DataType::Float16, |
| 2792 | DataType::Signed32 |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 2793 | }; |
| 2794 | supported &= CheckSupportRule(TypeAnyOf(biases.value(), biasesSupportedTypes), reasonIfUnsupported, |
| 2795 | "Reference TransposeConvolution2d: biases is not a supported type."); |
| 2796 | } |
| 2797 | |
| 2798 | return supported; |
| 2799 | } |
| 2800 | |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 2801 | bool RefLayerSupport::IsTransposeSupported(const TensorInfo& input, |
| 2802 | const TensorInfo& output, |
| 2803 | const TransposeDescriptor& descriptor, |
| 2804 | Optional<std::string&> reasonIfUnsupported) const |
| 2805 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2806 | IgnoreUnused(descriptor); |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 2807 | bool supported = true; |
| 2808 | |
| 2809 | // Define supported output and inputs types. |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2810 | std::array<DataType, 6> supportedTypes = |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 2811 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2812 | DataType::BFloat16, |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 2813 | DataType::Float32, |
| 2814 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2815 | DataType::QAsymmS8, |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 2816 | DataType::QAsymmU8, |
| 2817 | DataType::QSymmS16 |
| 2818 | }; |
| 2819 | |
| 2820 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2821 | "Reference transpose: input is not a supported type."); |
| 2822 | |
| 2823 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2824 | "Reference transpose: output is not a supported type."); |
| 2825 | |
| 2826 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2827 | "Reference transpose: input and output types are mismatched."); |
| 2828 | |
| 2829 | return supported; |
| 2830 | } |
| 2831 | |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2832 | bool RefLayerSupport::IsUnidirectionalSequenceLstmSupported( |
| 2833 | const TensorInfo& input, |
| 2834 | const TensorInfo& outputStateIn, |
| 2835 | const TensorInfo& cellStateIn, |
Mike Kelly | 1299496 | 2022-04-21 11:57:09 +0100 | [diff] [blame] | 2836 | const TensorInfo& outputStateOut, |
| 2837 | const TensorInfo& cellStateOut, |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2838 | const TensorInfo& output, |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2839 | const UnidirectionalSequenceLstmDescriptor& descriptor, |
| 2840 | const LstmInputParamsInfo& paramsInfo, |
| 2841 | Optional<std::string&> reasonIfUnsupported) const |
| 2842 | { |
| 2843 | IgnoreUnused(descriptor); |
| 2844 | IgnoreUnused(paramsInfo); |
| 2845 | IgnoreUnused(outputStateIn); |
| 2846 | IgnoreUnused(cellStateIn); |
Mike Kelly | 1299496 | 2022-04-21 11:57:09 +0100 | [diff] [blame] | 2847 | IgnoreUnused(outputStateOut); |
| 2848 | IgnoreUnused(cellStateOut); |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2849 | bool supported = true; |
| 2850 | |
Mike Kelly | 1299496 | 2022-04-21 11:57:09 +0100 | [diff] [blame] | 2851 | std::array<DataType, 2> supportedTypes = |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2852 | { |
Mike Kelly | 1299496 | 2022-04-21 11:57:09 +0100 | [diff] [blame] | 2853 | DataType::Float32, |
| 2854 | DataType::QAsymmS8 |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2855 | }; |
| 2856 | |
Narumol Prangnawarat | bd575b2 | 2021-08-31 16:53:54 +0100 | [diff] [blame] | 2857 | std::array<DataType, 2> supportedWeightTypes = |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2858 | { |
Narumol Prangnawarat | bd575b2 | 2021-08-31 16:53:54 +0100 | [diff] [blame] | 2859 | DataType::Float32, |
| 2860 | DataType::QAsymmS8 |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2861 | }; |
| 2862 | |
Mike Kelly | 1299496 | 2022-04-21 11:57:09 +0100 | [diff] [blame] | 2863 | std::array<DataType, 3> supportedBiasTypes = |
| 2864 | { |
| 2865 | DataType::Float32, |
| 2866 | DataType::QAsymmS8, |
| 2867 | DataType::Signed32 |
| 2868 | }; |
| 2869 | |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2870 | // check inputs and outputs |
| 2871 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2872 | "Reference UnidirectionalSequenceLstm: input is not a supported type."); |
Mike Kelly | 1299496 | 2022-04-21 11:57:09 +0100 | [diff] [blame] | 2873 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2874 | "Reference UnidirectionalSequenceLstm: output is not a supported type."); |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2875 | |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2876 | // check layer parameters |
| 2877 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetInputToForgetWeights(), supportedWeightTypes), |
| 2878 | reasonIfUnsupported, |
| 2879 | "Reference UnidirectionalSequenceLstm: InputToForgetWeights " |
| 2880 | "is not a supported type."); |
| 2881 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetInputToCellWeights(), supportedWeightTypes), |
| 2882 | reasonIfUnsupported, |
| 2883 | "Reference UnidirectionalSequenceLstm: InputToCellWeights is not a supported type."); |
| 2884 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetInputToOutputWeights(), supportedWeightTypes), |
| 2885 | reasonIfUnsupported, |
| 2886 | "Reference UnidirectionalSequenceLstm: InputToOutputWeights " |
| 2887 | "is not a supported type."); |
| 2888 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetRecurrentToForgetWeights(), supportedWeightTypes), |
| 2889 | reasonIfUnsupported, |
| 2890 | "Reference UnidirectionalSequenceLstm: RecurrentToForgetWeights " |
| 2891 | "is not a supported type."); |
| 2892 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetRecurrentToCellWeights(), supportedWeightTypes), |
| 2893 | reasonIfUnsupported, |
| 2894 | "Reference UnidirectionalSequenceLstm: RecurrentToCellWeights " |
| 2895 | "is not a supported type."); |
| 2896 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetRecurrentToOutputWeights(), supportedWeightTypes), |
| 2897 | reasonIfUnsupported, |
| 2898 | "Reference UnidirectionalSequenceLstm: RecurrentToOutputWeights " |
| 2899 | "is not a supported type."); |
Mike Kelly | 1299496 | 2022-04-21 11:57:09 +0100 | [diff] [blame] | 2900 | |
| 2901 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetForgetGateBias(), supportedBiasTypes), reasonIfUnsupported, |
| 2902 | "Reference UnidirectionalSequenceLstm: ForgetGateBias is not a supported type."); |
| 2903 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetCellBias(), supportedBiasTypes), reasonIfUnsupported, |
| 2904 | "Reference UnidirectionalSequenceLstm: CellBias is not a supported type."); |
| 2905 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetOutputGateBias(), supportedBiasTypes), reasonIfUnsupported, |
| 2906 | "Reference UnidirectionalSequenceLstm: OutputGateBias is not a supported type."); |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2907 | if (!descriptor.m_CifgEnabled) |
| 2908 | { |
| 2909 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetInputToInputWeights(), supportedWeightTypes), |
| 2910 | reasonIfUnsupported, |
| 2911 | "Reference UnidirectionalSequenceLstm: InputToInputWeights " |
| 2912 | "is not a supported type."); |
| 2913 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetRecurrentToInputWeights(), supportedWeightTypes), |
| 2914 | reasonIfUnsupported, |
| 2915 | "Reference UnidirectionalSequenceLstm: RecurrentToInputWeights " |
| 2916 | "is not a supported type."); |
Mike Kelly | 1299496 | 2022-04-21 11:57:09 +0100 | [diff] [blame] | 2917 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetInputGateBias(), supportedBiasTypes), reasonIfUnsupported, |
| 2918 | "Reference UnidirectionalSequenceLstm: InputGateBias is not a supported type."); |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2919 | if (descriptor.m_PeepholeEnabled) |
| 2920 | { |
| 2921 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetCellToInputWeights(), supportedWeightTypes), |
| 2922 | reasonIfUnsupported, |
| 2923 | "Reference UnidirectionalSequenceLstm: CellToInputWeights " |
| 2924 | "is not a supported type."); |
| 2925 | } |
| 2926 | } |
| 2927 | if (descriptor.m_PeepholeEnabled) |
| 2928 | { |
| 2929 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetCellToForgetWeights(), supportedWeightTypes), |
| 2930 | reasonIfUnsupported, |
| 2931 | "Reference UnidirectionalSequenceLstm: CellToForgetWeights " |
| 2932 | "is not a supported type."); |
| 2933 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetCellToOutputWeights(), supportedWeightTypes), |
| 2934 | reasonIfUnsupported, |
| 2935 | "Reference UnidirectionalSequenceLstm: CellToOutputWeights " |
| 2936 | "is not a supported type."); |
| 2937 | } |
| 2938 | if (descriptor.m_ProjectionEnabled) |
| 2939 | { |
| 2940 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetProjectionWeights(), supportedWeightTypes), |
| 2941 | reasonIfUnsupported, |
| 2942 | "Reference UnidirectionalSequenceLstm: ProjectionWeights " |
| 2943 | "is not a supported type."); |
| 2944 | if (paramsInfo.m_ProjectionBias != nullptr) |
| 2945 | { |
| 2946 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetProjectionBias()), reasonIfUnsupported, |
| 2947 | "Reference UnidirectionalSequenceLstm: input and ProjectionBias types " |
| 2948 | "are mismatched"); |
| 2949 | } |
| 2950 | } |
| 2951 | if (descriptor.m_LayerNormEnabled) |
| 2952 | { |
| 2953 | if (!descriptor.m_CifgEnabled) |
| 2954 | { |
| 2955 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetInputLayerNormWeights(), supportedWeightTypes), |
| 2956 | reasonIfUnsupported, |
| 2957 | "Reference UnidirectionalSequenceLstm: InputLayerNormWeights " |
| 2958 | "is not a supported type."); |
| 2959 | } |
| 2960 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetForgetLayerNormWeights(), supportedWeightTypes), |
| 2961 | reasonIfUnsupported, |
| 2962 | "Reference UnidirectionalSequenceLstm: ForgetLayerNormWeights " |
| 2963 | "is not a supported type."); |
| 2964 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetCellLayerNormWeights(), supportedWeightTypes), |
| 2965 | reasonIfUnsupported, |
| 2966 | "Reference UnidirectionalSequenceLstm: CellLayerNormWeights " |
| 2967 | "is not a supported type."); |
| 2968 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetOutputLayerNormWeights(), supportedWeightTypes), |
| 2969 | reasonIfUnsupported, |
| 2970 | "Reference UnidirectionalSequenceLstm: OutputLayerNormWeights " |
| 2971 | "is not a supported type."); |
| 2972 | } |
| 2973 | |
| 2974 | return supported; |
| 2975 | } |
| 2976 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 2977 | } // namespace armnn |