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