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