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