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