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