telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. 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 | 3e9e115 | 2018-10-17 14:17:50 +0100 | [diff] [blame] | 7 | #include "RefBackendId.hpp" |
David Beck | 3cc9a62 | 2018-10-12 10:38:31 +0100 | [diff] [blame] | 8 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 9 | #include <InternalTypes.hpp> |
| 10 | #include <LayerSupportCommon.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 11 | #include <armnn/Types.hpp> |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 12 | #include <armnn/Descriptors.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 13 | |
David Beck | 111b5d9 | 2018-11-12 14:59:37 +0000 | [diff] [blame] | 14 | #include <backendsCommon/BackendRegistry.hpp> |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 15 | #include <backendsCommon/test/WorkloadTestUtils.hpp> |
David Beck | 3e9e115 | 2018-10-17 14:17:50 +0100 | [diff] [blame] | 16 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 17 | #include <boost/core/ignore_unused.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 18 | |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 19 | #include <vector> |
| 20 | #include <algorithm> |
| 21 | #include <array> |
| 22 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 23 | using namespace boost; |
| 24 | |
| 25 | namespace armnn |
| 26 | { |
| 27 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 28 | namespace |
| 29 | { |
| 30 | |
| 31 | template<typename Float32Func, typename Uint8Func, typename ... Params> |
| 32 | bool IsSupportedForDataTypeRef(Optional<std::string&> reasonIfUnsupported, |
| 33 | DataType dataType, |
| 34 | Float32Func floatFuncPtr, |
| 35 | Uint8Func uint8FuncPtr, |
| 36 | Params&&... params) |
| 37 | { |
| 38 | return IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 39 | dataType, |
| 40 | &FalseFunc<Params...>, |
| 41 | floatFuncPtr, |
| 42 | uint8FuncPtr, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 43 | &FalseFunc<Params...>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 44 | &FalseFunc<Params...>, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 45 | std::forward<Params>(params)...); |
| 46 | } |
| 47 | |
| 48 | } // anonymous namespace |
| 49 | |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 50 | namespace |
| 51 | { |
| 52 | |
| 53 | std::string CreateIncorrectDimensionsErrorMsg(unsigned int expected, |
| 54 | unsigned int actual, |
| 55 | std::string& layerStr, |
| 56 | std::string& tensorName) |
| 57 | { |
| 58 | std::string errorMsg = "Reference " + layerStr + ": Expected " + std::to_string(expected) + " dimensions but got" + |
| 59 | " " + std::to_string(actual) + " dimensions instead, for the '" + tensorName + "' tensor."; |
| 60 | |
| 61 | return errorMsg; |
| 62 | } |
| 63 | |
| 64 | } // anonymous namespace |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 65 | |
| 66 | namespace |
| 67 | { |
| 68 | template<typename F> |
| 69 | bool CheckSupportRule(F rule, Optional<std::string&> reasonIfUnsupported, const char* reason) |
| 70 | { |
| 71 | bool supported = rule(); |
| 72 | if (!supported && reason) |
| 73 | { |
| 74 | reasonIfUnsupported.value() += std::string(reason) + "\n"; // Append the reason on a new line |
| 75 | } |
| 76 | return supported; |
| 77 | } |
| 78 | |
| 79 | struct Rule |
| 80 | { |
| 81 | bool operator()() const |
| 82 | { |
| 83 | return m_Res; |
| 84 | } |
| 85 | |
| 86 | bool m_Res = true; |
| 87 | }; |
| 88 | |
Derek Lamberti | 2a434a8 | 2019-03-20 13:07:57 +0000 | [diff] [blame] | 89 | template<typename T> |
| 90 | bool AllTypesAreEqualImpl(T t) |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 91 | { |
| 92 | return true; |
| 93 | } |
| 94 | |
| 95 | template<typename T, typename... Rest> |
| 96 | bool AllTypesAreEqualImpl(T t1, T t2, Rest... rest) |
| 97 | { |
| 98 | static_assert(std::is_same<T, TensorInfo>::value, "Type T must be a TensorInfo"); |
| 99 | |
Derek Lamberti | 2a434a8 | 2019-03-20 13:07:57 +0000 | [diff] [blame] | 100 | return (t1.GetDataType() == t2.GetDataType()) && AllTypesAreEqualImpl(t2, rest...); |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | struct TypesAreEqual : public Rule |
| 104 | { |
| 105 | template<typename ... Ts> |
| 106 | TypesAreEqual(const Ts&... ts) |
| 107 | { |
| 108 | m_Res = AllTypesAreEqualImpl(ts...); |
| 109 | } |
| 110 | }; |
| 111 | |
| 112 | struct QuantizationParametersAreEqual : public Rule |
| 113 | { |
| 114 | QuantizationParametersAreEqual(const TensorInfo& info0, const TensorInfo& info1) |
| 115 | { |
| 116 | m_Res = info0.GetQuantizationScale() == info1.GetQuantizationScale() && |
| 117 | info0.GetQuantizationOffset() == info1.GetQuantizationOffset(); |
| 118 | } |
| 119 | }; |
| 120 | |
| 121 | struct TypeAnyOf : public Rule |
| 122 | { |
| 123 | template<typename Container> |
| 124 | TypeAnyOf(const TensorInfo& info, const Container& c) |
| 125 | { |
| 126 | m_Res = std::any_of(c.begin(), c.end(), [&info](DataType dt) |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 127 | { |
| 128 | return dt == info.GetDataType(); |
| 129 | }); |
| 130 | } |
| 131 | }; |
| 132 | |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 133 | struct TypeIs : public Rule |
| 134 | { |
| 135 | TypeIs(const TensorInfo& info, DataType dt) |
| 136 | { |
| 137 | m_Res = dt == info.GetDataType(); |
| 138 | } |
| 139 | }; |
| 140 | |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 141 | struct BiasAndWeightsTypesMatch : public Rule |
| 142 | { |
| 143 | BiasAndWeightsTypesMatch(const TensorInfo& biases, const TensorInfo& weights) |
| 144 | { |
| 145 | m_Res = biases.GetDataType() == GetBiasTypeFromWeightsType(weights.GetDataType()).value(); |
| 146 | } |
| 147 | }; |
| 148 | |
| 149 | struct BiasAndWeightsTypesCompatible : public Rule |
| 150 | { |
| 151 | template<typename Container> |
| 152 | BiasAndWeightsTypesCompatible(const TensorInfo& info, const Container& c) |
| 153 | { |
| 154 | m_Res = std::any_of(c.begin(), c.end(), [&info](DataType dt) |
| 155 | { |
| 156 | return dt == GetBiasTypeFromWeightsType(info.GetDataType()).value(); |
| 157 | }); |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 158 | } |
| 159 | }; |
| 160 | |
| 161 | struct ShapesAreSameRank : public Rule |
| 162 | { |
| 163 | ShapesAreSameRank(const TensorInfo& info0, const TensorInfo& info1) |
| 164 | { |
| 165 | m_Res = info0.GetShape().GetNumDimensions() == info1.GetShape().GetNumDimensions(); |
| 166 | } |
| 167 | }; |
| 168 | |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 169 | struct ShapesAreSameTotalSize : public Rule |
| 170 | { |
| 171 | ShapesAreSameTotalSize(const TensorInfo& info0, const TensorInfo& info1) |
| 172 | { |
| 173 | m_Res = info0.GetNumElements() == info1.GetNumElements(); |
| 174 | } |
| 175 | }; |
| 176 | |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 177 | struct ShapesAreBroadcastCompatible : public Rule |
| 178 | { |
| 179 | unsigned int CalcInputSize(const TensorShape& in, const TensorShape& out, unsigned int idx) |
| 180 | { |
| 181 | unsigned int offset = out.GetNumDimensions() - in.GetNumDimensions(); |
| 182 | unsigned int sizeIn = (idx < offset) ? 1 : in[idx-offset]; |
| 183 | return sizeIn; |
| 184 | } |
| 185 | |
| 186 | ShapesAreBroadcastCompatible(const TensorInfo& in0, const TensorInfo& in1, const TensorInfo& out) |
| 187 | { |
| 188 | const TensorShape& shape0 = in0.GetShape(); |
| 189 | const TensorShape& shape1 = in1.GetShape(); |
| 190 | const TensorShape& outShape = out.GetShape(); |
| 191 | |
| 192 | for (unsigned int i=0; i < outShape.GetNumDimensions() && m_Res; i++) |
| 193 | { |
| 194 | unsigned int sizeOut = outShape[i]; |
| 195 | unsigned int sizeIn0 = CalcInputSize(shape0, outShape, i); |
| 196 | unsigned int sizeIn1 = CalcInputSize(shape1, outShape, i); |
| 197 | |
| 198 | m_Res &= ((sizeIn0 == sizeOut) || (sizeIn0 == 1)) && |
| 199 | ((sizeIn1 == sizeOut) || (sizeIn1 == 1)); |
| 200 | } |
| 201 | } |
| 202 | }; |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 203 | |
| 204 | struct TensorNumDimensionsAreCorrect : public Rule |
| 205 | { |
| 206 | TensorNumDimensionsAreCorrect(const TensorInfo& info, unsigned int expectedNumDimensions) |
| 207 | { |
| 208 | m_Res = info.GetNumDimensions() == expectedNumDimensions; |
| 209 | } |
| 210 | }; |
| 211 | |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 212 | } // namespace |
| 213 | |
| 214 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 215 | bool RefLayerSupport::IsActivationSupported(const TensorInfo& input, |
| 216 | const TensorInfo& output, |
| 217 | const ActivationDescriptor& descriptor, |
| 218 | Optional<std::string&> reasonIfUnsupported) const |
| 219 | { |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 220 | bool supported = true; |
| 221 | |
| 222 | // Define supported types. |
Teresa Charlin | 18515e2 | 2019-04-24 10:17:46 +0100 | [diff] [blame] | 223 | std::array<DataType,3> supportedTypes = { |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 224 | DataType::Float32, |
Teresa Charlin | 18515e2 | 2019-04-24 10:17:46 +0100 | [diff] [blame] | 225 | DataType::QuantisedAsymm8, |
| 226 | DataType::QuantisedSymm16 |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 227 | }; |
| 228 | |
| 229 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 230 | "Reference activation: input type not supported."); |
| 231 | |
| 232 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 233 | "Reference activation: output type not supported."); |
| 234 | |
| 235 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 236 | "Reference activation: input and output types mismatched."); |
| 237 | |
| 238 | supported &= CheckSupportRule(ShapesAreSameRank(input, output), reasonIfUnsupported, |
| 239 | "Reference activation: input and output shapes are of different rank."); |
| 240 | |
| 241 | |
| 242 | struct ActivationFunctionSupported : public Rule |
| 243 | { |
| 244 | ActivationFunctionSupported(const ActivationDescriptor& desc) |
| 245 | { |
| 246 | switch(desc.m_Function) |
| 247 | { |
| 248 | case ActivationFunction::Abs: |
| 249 | case ActivationFunction::BoundedReLu: |
| 250 | case ActivationFunction::LeakyReLu: |
| 251 | case ActivationFunction::Linear: |
| 252 | case ActivationFunction::ReLu: |
| 253 | case ActivationFunction::Sigmoid: |
| 254 | case ActivationFunction::SoftReLu: |
| 255 | case ActivationFunction::Sqrt: |
| 256 | case ActivationFunction::Square: |
| 257 | case ActivationFunction::TanH: |
| 258 | { |
| 259 | m_Res = true; |
| 260 | break; |
| 261 | } |
| 262 | default: |
| 263 | { |
| 264 | m_Res = false; |
| 265 | break; |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | }; |
| 270 | |
| 271 | // Function is supported |
| 272 | supported &= CheckSupportRule(ActivationFunctionSupported(descriptor), reasonIfUnsupported, |
| 273 | "Reference activation: function not supported."); |
| 274 | |
| 275 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | bool RefLayerSupport::IsAdditionSupported(const TensorInfo& input0, |
| 279 | const TensorInfo& input1, |
| 280 | const TensorInfo& output, |
| 281 | Optional<std::string&> reasonIfUnsupported) const |
| 282 | { |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 283 | bool supported = true; |
| 284 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 285 | std::array<DataType,3> supportedTypes = { |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 286 | DataType::Float32, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 287 | DataType::QuantisedAsymm8, |
| 288 | DataType::QuantisedSymm16 |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 289 | }; |
| 290 | |
| 291 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 292 | "Reference addition: input 0 is not a supported type."); |
| 293 | |
| 294 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 295 | "Reference addition: input 1 is not a supported type."); |
| 296 | |
| 297 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 298 | "Reference addition: output is not a supported type."); |
| 299 | |
| 300 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 301 | "Reference addition: input 0 and Input 1 types are mismatched"); |
| 302 | |
| 303 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 304 | "Reference addition: input and output types are mismatched"); |
| 305 | |
| 306 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 307 | "Reference addition: shapes are not suitable for implicit broadcast."); |
| 308 | |
| 309 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | bool RefLayerSupport::IsBatchNormalizationSupported(const TensorInfo& input, |
| 313 | const TensorInfo& output, |
| 314 | const TensorInfo& mean, |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 315 | const TensorInfo& variance, |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 316 | const TensorInfo& beta, |
| 317 | const TensorInfo& gamma, |
| 318 | const BatchNormalizationDescriptor& descriptor, |
| 319 | Optional<std::string&> reasonIfUnsupported) const |
| 320 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 321 | ignore_unused(descriptor); |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 322 | |
Matteo Martincigh | f550713 | 2019-06-04 10:59:47 +0100 | [diff] [blame] | 323 | std::array<DataType, 3> supportedTypes = |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 324 | { |
| 325 | DataType::Float32, |
Matteo Martincigh | f550713 | 2019-06-04 10:59:47 +0100 | [diff] [blame] | 326 | DataType::QuantisedAsymm8, |
| 327 | DataType::QuantisedSymm16 |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 328 | }; |
| 329 | |
| 330 | bool supported = true; |
| 331 | |
| 332 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 333 | "Reference batch normalization: input is not a supported type."); |
| 334 | |
| 335 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 336 | "Reference batch normalization: output is not a supported type."); |
| 337 | |
| 338 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 339 | "Reference batch normalization: input and output types are mismatched"); |
| 340 | |
| 341 | supported &= CheckSupportRule(TypeAnyOf(mean, supportedTypes), reasonIfUnsupported, |
| 342 | "Reference batch normalization: mean is not a supported type."); |
| 343 | |
| 344 | supported &= CheckSupportRule(TypeAnyOf(variance, supportedTypes), reasonIfUnsupported, |
| 345 | "Reference batch normalization: variance is not a supported type."); |
| 346 | |
| 347 | supported &= CheckSupportRule(TypeAnyOf(beta, supportedTypes), reasonIfUnsupported, |
| 348 | "Reference batch normalization: beta is not a supported type."); |
| 349 | |
| 350 | supported &= CheckSupportRule(TypeAnyOf(gamma, supportedTypes), reasonIfUnsupported, |
| 351 | "Reference batch normalization: gamma is not a supported type."); |
| 352 | |
| 353 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 354 | } |
| 355 | |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 356 | bool RefLayerSupport::IsBatchToSpaceNdSupported(const TensorInfo& input, |
| 357 | const TensorInfo& output, |
| 358 | const BatchToSpaceNdDescriptor& descriptor, |
| 359 | Optional<std::string&> reasonIfUnsupported) const |
| 360 | { |
| 361 | ignore_unused(descriptor); |
Francis Murtagh | d0dfe17 | 2019-06-25 10:57:10 +0100 | [diff] [blame] | 362 | |
| 363 | bool supported = true; |
| 364 | |
| 365 | std::string batchToSpaceNdLayerStr = "batchToSpaceNd"; |
| 366 | std::string inputTensorStr = "input"; |
| 367 | std::string outputTensorStr = "output"; |
| 368 | |
| 369 | // Define supported types. |
| 370 | std::array<DataType,3> supportedTypes = |
| 371 | { |
| 372 | DataType::Float32, |
| 373 | DataType::QuantisedAsymm8, |
| 374 | DataType::QuantisedSymm16 |
| 375 | }; |
| 376 | |
| 377 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 378 | "Reference BatchToSpaceNd: input type not supported."); |
| 379 | |
| 380 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 381 | "Reference BatchToSpaceNd: output type not supported."); |
| 382 | |
| 383 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 384 | "Reference BatchToSpaceNd: input and output types mismatched."); |
| 385 | |
| 386 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, 4), |
| 387 | reasonIfUnsupported, |
| 388 | CreateIncorrectDimensionsErrorMsg(4, |
| 389 | output.GetNumDimensions(), |
| 390 | batchToSpaceNdLayerStr, |
| 391 | outputTensorStr).data()); |
| 392 | |
| 393 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(input, 4), |
| 394 | reasonIfUnsupported, |
| 395 | CreateIncorrectDimensionsErrorMsg(4, |
| 396 | input.GetNumDimensions(), |
| 397 | batchToSpaceNdLayerStr, |
| 398 | inputTensorStr).data()); |
| 399 | |
| 400 | return supported; |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 401 | } |
| 402 | |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 403 | bool RefLayerSupport::IsConcatSupported(const std::vector<const TensorInfo*> inputs, |
| 404 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 405 | const ConcatDescriptor& descriptor, |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 406 | Optional<std::string&> reasonIfUnsupported) const |
| 407 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 408 | ignore_unused(descriptor); |
| 409 | |
| 410 | bool supported = true; |
| 411 | std::array<DataType,3> supportedTypes = |
| 412 | { |
| 413 | DataType::Float32, |
| 414 | DataType::QuantisedAsymm8, |
| 415 | DataType::QuantisedSymm16 |
| 416 | }; |
| 417 | |
| 418 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 419 | "Reference concatenation: output type not supported"); |
| 420 | for (const TensorInfo* input : inputs) |
| 421 | { |
| 422 | supported &= CheckSupportRule(TypeAnyOf(*input, supportedTypes), reasonIfUnsupported, |
| 423 | "Reference concatenation: input type not supported"); |
| 424 | |
| 425 | supported &= CheckSupportRule(TypesAreEqual(*input, output), reasonIfUnsupported, |
| 426 | "Reference concatenation: input and output types mismatched."); |
| 427 | } |
| 428 | |
| 429 | return supported; |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 430 | } |
| 431 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 432 | bool RefLayerSupport::IsConstantSupported(const TensorInfo& output, |
| 433 | Optional<std::string&> reasonIfUnsupported) const |
| 434 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 435 | std::array<DataType,4> supportedTypes = |
| 436 | { |
Nina Drozd | 58ef2c6 | 2019-05-16 12:09:18 +0100 | [diff] [blame] | 437 | DataType::Float32, |
| 438 | DataType::Signed32, |
| 439 | DataType::QuantisedAsymm8, |
| 440 | DataType::QuantisedSymm16 |
| 441 | }; |
| 442 | |
| 443 | return CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 444 | "Reference constant: output is not a supported type."); |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | bool RefLayerSupport::IsConvertFp16ToFp32Supported(const TensorInfo& input, |
| 448 | const TensorInfo& output, |
| 449 | Optional<std::string&> reasonIfUnsupported) const |
| 450 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 451 | return (IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 452 | input.GetDataType(), |
| 453 | &TrueFunc<>, |
| 454 | &FalseInputFuncF32<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 455 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 456 | &FalseFuncI32<>, |
| 457 | &FalseFuncU8<>) && |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 458 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 459 | output.GetDataType(), |
| 460 | &FalseOutputFuncF16<>, |
| 461 | &TrueFunc<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 462 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 463 | &FalseFuncI32<>, |
| 464 | &FalseFuncU8<>)); |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | bool RefLayerSupport::IsConvertFp32ToFp16Supported(const TensorInfo& input, |
| 468 | const TensorInfo& output, |
| 469 | Optional<std::string&> reasonIfUnsupported) const |
| 470 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 471 | return (IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 472 | input.GetDataType(), |
| 473 | &FalseInputFuncF16<>, |
| 474 | &TrueFunc<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 475 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 476 | &FalseFuncI32<>, |
| 477 | &FalseFuncU8<>) && |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 478 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 479 | output.GetDataType(), |
| 480 | &TrueFunc<>, |
| 481 | &FalseOutputFuncF32<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 482 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 483 | &FalseFuncI32<>, |
| 484 | &FalseFuncU8<>)); |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | bool RefLayerSupport::IsConvolution2dSupported(const TensorInfo& input, |
| 488 | const TensorInfo& output, |
| 489 | const Convolution2dDescriptor& descriptor, |
| 490 | const TensorInfo& weights, |
| 491 | const Optional<TensorInfo>& biases, |
| 492 | Optional<std::string&> reasonIfUnsupported) const |
| 493 | { |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 494 | bool supported = true; |
| 495 | |
| 496 | // Define supported types. |
| 497 | std::array<DataType,3> supportedTypes = { |
| 498 | DataType::Float32, |
| 499 | DataType::QuantisedAsymm8, |
| 500 | DataType::QuantisedSymm16 |
| 501 | }; |
| 502 | |
| 503 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
Les Bell | d7f2908 | 2019-05-30 09:08:51 +0100 | [diff] [blame] | 504 | "Reference convolution2d: input is not a supported type."); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 505 | |
| 506 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
Les Bell | d7f2908 | 2019-05-30 09:08:51 +0100 | [diff] [blame] | 507 | "Reference convolution2d: output is not a supported type."); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 508 | |
| 509 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
Les Bell | d7f2908 | 2019-05-30 09:08:51 +0100 | [diff] [blame] | 510 | "Reference convolution2d: weights is not a supported type."); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 511 | |
| 512 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
Les Bell | d7f2908 | 2019-05-30 09:08:51 +0100 | [diff] [blame] | 513 | "Reference convolution2d: input and output types mismatched."); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 514 | |
| 515 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
Les Bell | d7f2908 | 2019-05-30 09:08:51 +0100 | [diff] [blame] | 516 | "Reference convolution2d: input and weights types mismatched."); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 517 | |
| 518 | if (biases.has_value()) |
| 519 | { |
| 520 | std::array<DataType,3> biasesSupportedTypes = { |
| 521 | DataType::Float32, |
| 522 | DataType::Signed32 |
| 523 | }; |
| 524 | supported &= CheckSupportRule(TypeAnyOf(biases.value(), biasesSupportedTypes), reasonIfUnsupported, |
Les Bell | d7f2908 | 2019-05-30 09:08:51 +0100 | [diff] [blame] | 525 | "Reference convolution2d: biases is not a supported type."); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 526 | } |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 527 | ignore_unused(descriptor); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 528 | |
| 529 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 530 | } |
| 531 | |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 532 | bool RefLayerSupport::IsDebugSupported(const TensorInfo& input, |
| 533 | const TensorInfo& output, |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 534 | Optional<std::string&> reasonIfUnsupported) const |
| 535 | { |
| 536 | ignore_unused(output); |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 537 | return IsSupportedForDataTypeRef(reasonIfUnsupported, |
| 538 | input.GetDataType(), |
| 539 | &TrueFunc<>, |
| 540 | &TrueFunc<>); |
| 541 | } |
| 542 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 543 | bool RefLayerSupport::IsDepthwiseConvolutionSupported(const TensorInfo& input, |
| 544 | const TensorInfo& output, |
| 545 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 546 | const TensorInfo& weights, |
| 547 | const Optional<TensorInfo>& biases, |
| 548 | Optional<std::string&> reasonIfUnsupported) const |
| 549 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 550 | ignore_unused(output); |
| 551 | ignore_unused(descriptor); |
| 552 | ignore_unused(weights); |
| 553 | ignore_unused(biases); |
| 554 | return IsSupportedForDataTypeRef(reasonIfUnsupported, |
| 555 | input.GetDataType(), |
| 556 | &TrueFunc<>, |
| 557 | &TrueFunc<>); |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 558 | } |
| 559 | |
Nattapat Chaimanowong | 8a54ac0 | 2019-03-29 15:25:04 +0000 | [diff] [blame] | 560 | bool RefLayerSupport::IsDequantizeSupported(const TensorInfo& input, |
| 561 | const TensorInfo& output, |
| 562 | Optional<std::string&> reasonIfUnsupported) const |
| 563 | { |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 564 | bool supported = true; |
| 565 | |
| 566 | std::array<DataType,2> supportedInputTypes = { |
| 567 | DataType::QuantisedAsymm8, |
| 568 | DataType::QuantisedSymm16 |
| 569 | }; |
| 570 | |
| 571 | supported &= CheckSupportRule(TypeAnyOf(input, supportedInputTypes), reasonIfUnsupported, |
| 572 | "Reference dequantize: input type not supported."); |
| 573 | |
| 574 | std::array<DataType,2> supportedOutputTypes = { |
| 575 | DataType::Float32, |
| 576 | }; |
| 577 | |
| 578 | supported &= CheckSupportRule(TypeAnyOf(output, supportedOutputTypes), reasonIfUnsupported, |
| 579 | "Reference dequantize: output type not supported."); |
| 580 | |
| 581 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 582 | "Reference dequantize: input and output shapes have different num total elements."); |
| 583 | |
| 584 | return supported; |
Nattapat Chaimanowong | 8a54ac0 | 2019-03-29 15:25:04 +0000 | [diff] [blame] | 585 | } |
| 586 | |
Narumol Prangnawarat | bc67cef | 2019-01-31 15:31:54 +0000 | [diff] [blame] | 587 | bool RefLayerSupport::IsDetectionPostProcessSupported(const armnn::TensorInfo& input0, |
| 588 | const armnn::TensorInfo& input1, |
| 589 | const armnn::DetectionPostProcessDescriptor& descriptor, |
| 590 | armnn::Optional<std::string&> reasonIfUnsupported) const |
| 591 | { |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 592 | bool supported = true; |
| 593 | |
| 594 | std::vector<DataType> supportedInputTypes = |
| 595 | { |
| 596 | DataType::Float32, |
| 597 | DataType::QuantisedAsymm8, |
| 598 | DataType::QuantisedSymm16 |
| 599 | }; |
| 600 | |
| 601 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedInputTypes), reasonIfUnsupported, |
| 602 | "Reference DetectionPostProcess: input 0 is not a supported type."); |
| 603 | |
| 604 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedInputTypes), reasonIfUnsupported, |
| 605 | "Reference DetectionPostProcess: input 1 is not a supported type."); |
| 606 | |
| 607 | return supported; |
Narumol Prangnawarat | bc67cef | 2019-01-31 15:31:54 +0000 | [diff] [blame] | 608 | } |
| 609 | |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 610 | bool RefLayerSupport::IsDilatedDepthwiseConvolutionSupported(const TensorInfo& input, |
| 611 | const TensorInfo& output, |
| 612 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 613 | const TensorInfo& weights, |
| 614 | const Optional<TensorInfo>& biases, |
| 615 | Optional<std::string&> reasonIfUnsupported) const |
| 616 | { |
Aron Virginas-Tar | aece4ed | 2019-06-14 17:00:09 +0100 | [diff] [blame] | 617 | return IsDepthwiseConvolutionSupported(input, output, descriptor, weights, biases, reasonIfUnsupported); |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 618 | } |
| 619 | |
Aron Virginas-Tar | aece4ed | 2019-06-14 17:00:09 +0100 | [diff] [blame] | 620 | bool RefLayerSupport::IsDivisionSupported(const TensorInfo& input0, |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 621 | const TensorInfo& input1, |
| 622 | const TensorInfo& output, |
| 623 | Optional<std::string&> reasonIfUnsupported) const |
| 624 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 625 | bool supported = true; |
| 626 | |
| 627 | std::array<DataType,3> supportedTypes = { |
| 628 | DataType::Float32, |
| 629 | DataType::QuantisedAsymm8, |
| 630 | DataType::QuantisedSymm16 |
| 631 | }; |
| 632 | |
| 633 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 634 | "Reference division: input 0 is not a supported type."); |
| 635 | |
| 636 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 637 | "Reference division: input 1 is not a supported type."); |
| 638 | |
| 639 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 640 | "Reference division: output is not a supported type."); |
| 641 | |
| 642 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 643 | "Reference division: input 0 and Input 1 types are mismatched"); |
| 644 | |
| 645 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 646 | "Reference division: input and output types are mismatched"); |
| 647 | |
| 648 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 649 | "Reference division: shapes are not suitable for implicit broadcast."); |
| 650 | |
| 651 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 652 | } |
| 653 | |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 654 | bool RefLayerSupport::IsEqualSupported(const TensorInfo& input0, |
| 655 | const TensorInfo& input1, |
| 656 | const TensorInfo& output, |
| 657 | Optional<std::string&> reasonIfUnsupported) const |
| 658 | { |
| 659 | ignore_unused(input0); |
| 660 | ignore_unused(input1); |
| 661 | ignore_unused(output); |
| 662 | ignore_unused(reasonIfUnsupported); |
| 663 | return IsSupportedForDataTypeRef(reasonIfUnsupported, |
| 664 | input0.GetDataType(), |
| 665 | &TrueFunc<>, |
| 666 | &TrueFunc<>); |
| 667 | } |
| 668 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 669 | bool RefLayerSupport::IsFakeQuantizationSupported(const TensorInfo& input, |
| 670 | const FakeQuantizationDescriptor& descriptor, |
| 671 | Optional<std::string&> reasonIfUnsupported) const |
| 672 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 673 | ignore_unused(descriptor); |
| 674 | return IsSupportedForDataTypeRef(reasonIfUnsupported, |
| 675 | input.GetDataType(), |
| 676 | &TrueFunc<>, |
| 677 | &FalseFuncU8<>); |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | bool RefLayerSupport::IsFloorSupported(const TensorInfo& input, |
| 681 | const TensorInfo& output, |
| 682 | Optional<std::string&> reasonIfUnsupported) const |
| 683 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 684 | ignore_unused(output); |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 685 | bool supported = true; |
| 686 | |
James Conroy | b40d710 | 2019-06-04 12:32:09 +0100 | [diff] [blame] | 687 | std::array<DataType,2> supportedTypes = |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 688 | { |
James Conroy | b40d710 | 2019-06-04 12:32:09 +0100 | [diff] [blame] | 689 | DataType::Float32, |
| 690 | DataType::QuantisedSymm16 |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 691 | }; |
| 692 | |
| 693 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 694 | "Reference Floor: input type not supported."); |
| 695 | |
| 696 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 697 | "Reference Floor: output type not supported."); |
| 698 | |
| 699 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 700 | } |
| 701 | |
| 702 | bool RefLayerSupport::IsFullyConnectedSupported(const TensorInfo& input, |
| 703 | const TensorInfo& output, |
| 704 | const TensorInfo& weights, |
| 705 | const TensorInfo& biases, |
| 706 | const FullyConnectedDescriptor& descriptor, |
| 707 | Optional<std::string&> reasonIfUnsupported) const |
| 708 | { |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 709 | bool supported = true; |
| 710 | |
| 711 | // Define supported types. |
| 712 | std::array<DataType,3> supportedTypes = |
| 713 | { |
| 714 | DataType::Float32, |
| 715 | DataType::QuantisedAsymm8, |
| 716 | DataType::QuantisedSymm16 |
| 717 | }; |
| 718 | |
| 719 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 720 | "Reference Fully Connected: input type not supported."); |
| 721 | |
| 722 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 723 | "Reference Fully Connected: output type not supported."); |
| 724 | |
| 725 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 726 | "Reference Fully Connected: input and output types mismatched."); |
| 727 | |
| 728 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 729 | "Reference Fully Connected: weights type not supported."); |
| 730 | |
| 731 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 732 | "Reference Fully Connected: input and weight types mismatched."); |
| 733 | |
| 734 | if (descriptor.m_BiasEnabled) |
| 735 | { |
| 736 | // Defined supported types for bias |
| 737 | std::array<DataType, 2> |
| 738 | supportedBiasTypes = |
| 739 | { |
| 740 | DataType::Float32, |
| 741 | DataType::Signed32 |
| 742 | }; |
| 743 | |
| 744 | supported &= CheckSupportRule(TypeAnyOf(biases, supportedBiasTypes), reasonIfUnsupported, |
| 745 | "Reference Fully Connected: bias type not supported."); |
| 746 | |
| 747 | supported &= CheckSupportRule(BiasAndWeightsTypesMatch(biases, weights), reasonIfUnsupported, |
| 748 | "Reference Fully Connected: bias and weight types mismatch."); |
| 749 | |
| 750 | supported &= CheckSupportRule(BiasAndWeightsTypesCompatible(weights, supportedBiasTypes), reasonIfUnsupported, |
| 751 | "Reference Fully Connected: bias type inferred from weights is incompatible."); |
| 752 | |
| 753 | } |
| 754 | |
| 755 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 756 | } |
| 757 | |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 758 | bool RefLayerSupport::IsGatherSupported(const armnn::TensorInfo& input0, |
| 759 | const armnn::TensorInfo& input1, |
| 760 | const armnn::TensorInfo& output, |
| 761 | armnn::Optional<std::string&> reasonIfUnsupported) const |
| 762 | { |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 763 | bool supported = true; |
| 764 | std::array<DataType,3> supportedTypes = |
| 765 | { |
| 766 | DataType::Float32, |
| 767 | DataType::QuantisedAsymm8, |
| 768 | DataType::QuantisedSymm16 |
| 769 | }; |
| 770 | |
| 771 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 772 | "Reference Gather: input type not supported"); |
| 773 | |
| 774 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 775 | "Reference Gather: output type not supported"); |
| 776 | |
| 777 | supported &= CheckSupportRule(TypeIs(input1, DataType::Signed32), reasonIfUnsupported, |
| 778 | "Reference Gather: indices (input1) type not supported"); |
| 779 | |
| 780 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 781 | "Reference Gather: input and output types not matching"); |
| 782 | |
| 783 | return supported; |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 784 | } |
| 785 | |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 786 | bool RefLayerSupport::IsGreaterSupported(const TensorInfo& input0, |
| 787 | const TensorInfo& input1, |
| 788 | const TensorInfo& output, |
| 789 | Optional<std::string&> reasonIfUnsupported) const |
| 790 | { |
| 791 | ignore_unused(input0); |
| 792 | ignore_unused(input1); |
| 793 | ignore_unused(output); |
| 794 | ignore_unused(reasonIfUnsupported); |
| 795 | return IsSupportedForDataTypeRef(reasonIfUnsupported, |
| 796 | input0.GetDataType(), |
| 797 | &TrueFunc<>, |
| 798 | &TrueFunc<>); |
| 799 | } |
| 800 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 801 | bool RefLayerSupport::IsInputSupported(const TensorInfo& input, |
| 802 | Optional<std::string&> reasonIfUnsupported) const |
| 803 | { |
Narumol Prangnawarat | b6441e4 | 2019-06-04 11:22:00 +0100 | [diff] [blame] | 804 | return true; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 805 | } |
| 806 | |
| 807 | bool RefLayerSupport::IsL2NormalizationSupported(const TensorInfo& input, |
| 808 | const TensorInfo& output, |
| 809 | const L2NormalizationDescriptor& descriptor, |
| 810 | Optional<std::string&> reasonIfUnsupported) const |
| 811 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 812 | ignore_unused(descriptor); |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 813 | // Define supported types |
Ferran Balaguer | c6138d8 | 2019-06-13 17:23:50 +0100 | [diff] [blame] | 814 | std::array<DataType, 3> supportedTypes = |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 815 | { |
| 816 | DataType::Float32, |
Ferran Balaguer | c6138d8 | 2019-06-13 17:23:50 +0100 | [diff] [blame] | 817 | DataType::QuantisedAsymm8, |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 818 | DataType::QuantisedSymm16 |
| 819 | }; |
| 820 | |
| 821 | bool supported = true; |
| 822 | |
| 823 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 824 | "Reference L2normalization: input type not supported."); |
| 825 | |
| 826 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 827 | "Reference L2normalization: output type not supported."); |
| 828 | |
| 829 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 830 | "Reference L2normalization: input and output types mismatched."); |
| 831 | |
| 832 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 833 | "Reference L2normalization: input and output shapes have different " |
| 834 | "num total elements."); |
| 835 | |
| 836 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 837 | } |
| 838 | |
| 839 | bool RefLayerSupport::IsLstmSupported(const TensorInfo& input, |
| 840 | const TensorInfo& outputStateIn, |
| 841 | const TensorInfo& cellStateIn, |
| 842 | const TensorInfo& scratchBuffer, |
| 843 | const TensorInfo& outputStateOut, |
| 844 | const TensorInfo& cellStateOut, |
| 845 | const TensorInfo& output, |
| 846 | const LstmDescriptor& descriptor, |
| 847 | const TensorInfo& inputToForgetWeights, |
| 848 | const TensorInfo& inputToCellWeights, |
| 849 | const TensorInfo& inputToOutputWeights, |
| 850 | const TensorInfo& recurrentToForgetWeights, |
| 851 | const TensorInfo& recurrentToCellWeights, |
| 852 | const TensorInfo& recurrentToOutputWeights, |
| 853 | const TensorInfo& forgetGateBias, |
| 854 | const TensorInfo& cellBias, |
| 855 | const TensorInfo& outputGateBias, |
| 856 | const TensorInfo* inputToInputWeights, |
| 857 | const TensorInfo* recurrentToInputWeights, |
| 858 | const TensorInfo* cellToInputWeights, |
| 859 | const TensorInfo* inputGateBias, |
| 860 | const TensorInfo* projectionWeights, |
| 861 | const TensorInfo* projectionBias, |
| 862 | const TensorInfo* cellToForgetWeights, |
| 863 | const TensorInfo* cellToOutputWeights, |
| 864 | Optional<std::string&> reasonIfUnsupported) const |
| 865 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 866 | ignore_unused(descriptor); |
| 867 | ignore_unused(inputToForgetWeights); |
| 868 | ignore_unused(inputToCellWeights); |
| 869 | ignore_unused(inputToOutputWeights); |
| 870 | ignore_unused(recurrentToForgetWeights); |
| 871 | ignore_unused(recurrentToCellWeights); |
| 872 | ignore_unused(recurrentToOutputWeights); |
| 873 | ignore_unused(forgetGateBias); |
| 874 | ignore_unused(cellBias); |
| 875 | ignore_unused(outputGateBias); |
| 876 | ignore_unused(inputToInputWeights); |
| 877 | ignore_unused(recurrentToInputWeights); |
| 878 | ignore_unused(cellToInputWeights); |
| 879 | ignore_unused(inputGateBias); |
| 880 | ignore_unused(projectionWeights); |
| 881 | ignore_unused(projectionBias); |
| 882 | ignore_unused(cellToForgetWeights); |
| 883 | ignore_unused(cellToOutputWeights); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 884 | |
| 885 | bool supported = true; |
| 886 | |
| 887 | std::array<DataType,2> supportedTypes = { |
Conor Kennedy | b9971c9 | 2019-05-07 07:14:23 +0100 | [diff] [blame] | 888 | DataType::Float32, |
| 889 | DataType::QuantisedSymm16 |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 890 | }; |
| 891 | |
| 892 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 893 | "Reference Lstm: input is not a supported type."); |
| 894 | |
| 895 | supported &= CheckSupportRule(TypesAreEqual(input, outputStateIn), reasonIfUnsupported, |
| 896 | "Reference Lstm: input and outputStateIn types are mismatched"); |
| 897 | |
| 898 | supported &= CheckSupportRule(TypesAreEqual(input, cellStateIn), reasonIfUnsupported, |
| 899 | "Reference Lstm: input and cellStateIn types are mismatched"); |
| 900 | |
| 901 | supported &= CheckSupportRule(TypesAreEqual(input, scratchBuffer), reasonIfUnsupported, |
| 902 | "Reference Lstm: input and scratchBuffer types are mismatched"); |
| 903 | |
| 904 | supported &= CheckSupportRule(TypesAreEqual(input, outputStateOut), reasonIfUnsupported, |
| 905 | "Reference Lstm: input and outputStateOut types are mismatched"); |
| 906 | |
| 907 | supported &= CheckSupportRule(TypesAreEqual(input, cellStateOut), reasonIfUnsupported, |
| 908 | "Reference Lstm: input and cellStateOut types are mismatched"); |
| 909 | |
| 910 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 911 | "Reference Lstm: input and output types are mismatched"); |
| 912 | |
| 913 | return supported; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 914 | } |
| 915 | |
saoste01 | 2df12b3 | 2018-11-28 16:57:20 +0000 | [diff] [blame] | 916 | bool RefLayerSupport::IsMaximumSupported(const TensorInfo& input0, |
| 917 | const TensorInfo& input1, |
| 918 | const TensorInfo& output, |
| 919 | Optional<std::string&> reasonIfUnsupported) const |
| 920 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 921 | bool supported = true; |
| 922 | |
| 923 | std::array<DataType,3> supportedTypes = { |
| 924 | DataType::Float32, |
| 925 | DataType::QuantisedAsymm8, |
| 926 | DataType::QuantisedSymm16 |
| 927 | }; |
| 928 | |
| 929 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 930 | "Reference maximum: input 0 is not a supported type."); |
| 931 | |
| 932 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 933 | "Reference maximum: input 1 is not a supported type."); |
| 934 | |
| 935 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 936 | "Reference maximum: output is not a supported type."); |
| 937 | |
| 938 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 939 | "Reference maximum: input 0 and Input 1 types are mismatched"); |
| 940 | |
| 941 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 942 | "Reference maximum: input and output types are mismatched"); |
| 943 | |
| 944 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 945 | "Reference maximum: shapes are not suitable for implicit broadcast."); |
| 946 | |
| 947 | return supported; |
saoste01 | 2df12b3 | 2018-11-28 16:57:20 +0000 | [diff] [blame] | 948 | } |
| 949 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 950 | bool RefLayerSupport::IsMeanSupported(const TensorInfo& input, |
| 951 | const TensorInfo& output, |
| 952 | const MeanDescriptor& descriptor, |
| 953 | Optional<std::string&> reasonIfUnsupported) const |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 954 | { |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 955 | bool supported = true; |
| 956 | std::string meanLayerStr = "Mean"; |
| 957 | std::string outputTensorStr = "output"; |
| 958 | |
James Conroy | b80775f | 2019-06-11 11:25:30 +0100 | [diff] [blame] | 959 | std::array<DataType,3> supportedTypes = |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 960 | { |
| 961 | DataType::Float32, |
James Conroy | b80775f | 2019-06-11 11:25:30 +0100 | [diff] [blame] | 962 | DataType::QuantisedAsymm8, |
| 963 | DataType::QuantisedSymm16 |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 964 | }; |
| 965 | |
| 966 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 967 | "Reference Mean: input type not supported."); |
| 968 | |
| 969 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 970 | "Reference Mean: input and output types are mismatched"); |
| 971 | |
| 972 | if (descriptor.m_KeepDims) |
| 973 | { |
| 974 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, input.GetNumDimensions()), |
| 975 | reasonIfUnsupported, |
| 976 | CreateIncorrectDimensionsErrorMsg(input.GetNumDimensions(), |
| 977 | output.GetNumDimensions(), |
| 978 | meanLayerStr, outputTensorStr).data()); |
| 979 | } |
| 980 | else if (descriptor.m_Axis.empty()) |
| 981 | { |
| 982 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, 1), |
| 983 | reasonIfUnsupported, |
| 984 | CreateIncorrectDimensionsErrorMsg(1, output.GetNumDimensions(), |
| 985 | meanLayerStr, outputTensorStr).data()); |
| 986 | } |
| 987 | else |
| 988 | { |
| 989 | auto outputDim = input.GetNumDimensions() - boost::numeric_cast<unsigned int>(descriptor.m_Axis.size()); |
| 990 | |
| 991 | if (outputDim > 0) |
| 992 | { |
| 993 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, outputDim), |
| 994 | reasonIfUnsupported, |
| 995 | CreateIncorrectDimensionsErrorMsg(outputDim, output.GetNumDimensions(), |
| 996 | meanLayerStr, outputTensorStr).data()); |
| 997 | } |
| 998 | else |
| 999 | { |
| 1000 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, 1), |
| 1001 | reasonIfUnsupported, |
| 1002 | CreateIncorrectDimensionsErrorMsg(1, output.GetNumDimensions(), |
| 1003 | meanLayerStr, outputTensorStr).data()); |
| 1004 | } |
| 1005 | } |
| 1006 | |
| 1007 | return supported; |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 1008 | } |
| 1009 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1010 | bool RefLayerSupport::IsMergerSupported(const std::vector<const TensorInfo*> inputs, |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 1011 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1012 | const MergerDescriptor& descriptor, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1013 | Optional<std::string&> reasonIfUnsupported) const |
| 1014 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1015 | return IsConcatSupported(inputs, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1016 | } |
| 1017 | |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1018 | bool RefLayerSupport::IsMemCopySupported(const TensorInfo &input, |
| 1019 | const TensorInfo &output, |
| 1020 | Optional<std::string &> reasonIfUnsupported) const |
| 1021 | { |
| 1022 | ignore_unused(output); |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 1023 | return IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 1024 | input.GetDataType(), |
| 1025 | &TrueFunc<>, |
| 1026 | &TrueFunc<>, |
| 1027 | &TrueFunc<>, |
| 1028 | &FalseFuncI32<>, |
| 1029 | &TrueFunc<>); |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1030 | } |
| 1031 | |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 1032 | bool RefLayerSupport::IsMinimumSupported(const TensorInfo& input0, |
| 1033 | const TensorInfo& input1, |
| 1034 | const TensorInfo& output, |
| 1035 | Optional<std::string&> reasonIfUnsupported) const |
| 1036 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1037 | bool supported = true; |
| 1038 | |
| 1039 | std::array<DataType,3> supportedTypes = { |
| 1040 | DataType::Float32, |
| 1041 | DataType::QuantisedAsymm8, |
| 1042 | DataType::QuantisedSymm16 |
| 1043 | }; |
| 1044 | |
| 1045 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1046 | "Reference minimum: input 0 is not a supported type."); |
| 1047 | |
| 1048 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1049 | "Reference minimum: input 1 is not a supported type."); |
| 1050 | |
| 1051 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1052 | "Reference minimum: output is not a supported type."); |
| 1053 | |
| 1054 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1055 | "Reference minimum: input 0 and Input 1 types are mismatched"); |
| 1056 | |
| 1057 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1058 | "Reference minimum: input and output types are mismatched"); |
| 1059 | |
| 1060 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1061 | "Reference minimum: shapes are not suitable for implicit broadcast."); |
| 1062 | |
| 1063 | return supported; |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 1064 | } |
| 1065 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1066 | bool RefLayerSupport::IsMultiplicationSupported(const TensorInfo& input0, |
| 1067 | const TensorInfo& input1, |
| 1068 | const TensorInfo& output, |
| 1069 | Optional<std::string&> reasonIfUnsupported) const |
| 1070 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1071 | bool supported = true; |
| 1072 | |
| 1073 | std::array<DataType,3> supportedTypes = { |
| 1074 | DataType::Float32, |
| 1075 | DataType::QuantisedAsymm8, |
| 1076 | DataType::QuantisedSymm16 |
| 1077 | }; |
| 1078 | |
| 1079 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1080 | "Reference multiplication: input 0 is not a supported type."); |
| 1081 | |
| 1082 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1083 | "Reference multiplication: input 1 is not a supported type."); |
| 1084 | |
| 1085 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1086 | "Reference multiplication: output is not a supported type."); |
| 1087 | |
| 1088 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1089 | "Reference multiplication: input 0 and Input 1 types are mismatched"); |
| 1090 | |
| 1091 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1092 | "Reference multiplication: input and output types are mismatched"); |
| 1093 | |
| 1094 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1095 | "Reference multiplication: shapes are not suitable for implicit broadcast."); |
| 1096 | |
| 1097 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1098 | } |
| 1099 | |
| 1100 | bool RefLayerSupport::IsNormalizationSupported(const TensorInfo& input, |
| 1101 | const TensorInfo& output, |
| 1102 | const NormalizationDescriptor& descriptor, |
| 1103 | Optional<std::string&> reasonIfUnsupported) const |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 1104 | { |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 1105 | ignore_unused(descriptor); |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1106 | |
| 1107 | // Define supported types |
Matteo Martincigh | 6aeb771 | 2019-06-05 17:23:29 +0100 | [diff] [blame] | 1108 | std::array<DataType, 4> supportedTypes = |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1109 | { |
| 1110 | DataType::Float16, |
| 1111 | DataType::Float32, |
Matteo Martincigh | 6aeb771 | 2019-06-05 17:23:29 +0100 | [diff] [blame] | 1112 | DataType::QuantisedAsymm8, |
| 1113 | DataType::QuantisedSymm16 |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1114 | }; |
| 1115 | |
| 1116 | bool supported = true; |
| 1117 | |
| 1118 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1119 | "Reference normalization: input type not supported."); |
| 1120 | |
| 1121 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1122 | "Reference normalization: output type not supported."); |
| 1123 | |
| 1124 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1125 | "Reference normalization: input and output shapes have different " |
| 1126 | "num total elements."); |
| 1127 | |
| 1128 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1129 | } |
| 1130 | |
| 1131 | bool RefLayerSupport::IsOutputSupported(const TensorInfo& output, |
| 1132 | Optional<std::string&> reasonIfUnsupported) const |
| 1133 | { |
Narumol Prangnawarat | b6441e4 | 2019-06-04 11:22:00 +0100 | [diff] [blame] | 1134 | return true; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1135 | } |
| 1136 | |
| 1137 | bool RefLayerSupport::IsPadSupported(const TensorInfo& input, |
| 1138 | const TensorInfo& output, |
| 1139 | const PadDescriptor& descriptor, |
| 1140 | Optional<std::string&> reasonIfUnsupported) const |
| 1141 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1142 | ignore_unused(output); |
| 1143 | ignore_unused(descriptor); |
jimfly01 | f6ba747 | 2018-12-04 10:09:52 +0000 | [diff] [blame] | 1144 | return IsSupportedForDataTypeRef(reasonIfUnsupported, |
| 1145 | input.GetDataType(), |
| 1146 | &TrueFunc<>, |
| 1147 | &TrueFunc<>); |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 1148 | } |
| 1149 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1150 | bool RefLayerSupport::IsPermuteSupported(const TensorInfo& input, |
| 1151 | const TensorInfo& output, |
| 1152 | const PermuteDescriptor& descriptor, |
| 1153 | Optional<std::string&> reasonIfUnsupported) const |
| 1154 | { |
| 1155 | ignore_unused(output); |
| 1156 | ignore_unused(descriptor); |
| 1157 | return IsSupportedForDataTypeRef(reasonIfUnsupported, |
| 1158 | input.GetDataType(), |
| 1159 | &TrueFunc<>, |
| 1160 | &TrueFunc<>); |
| 1161 | } |
| 1162 | |
| 1163 | bool RefLayerSupport::IsPooling2dSupported(const TensorInfo& input, |
| 1164 | const TensorInfo& output, |
| 1165 | const Pooling2dDescriptor& descriptor, |
| 1166 | Optional<std::string&> reasonIfUnsupported) const |
| 1167 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1168 | ignore_unused(descriptor); |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1169 | bool supported = true; |
| 1170 | |
| 1171 | // Define supported output and inputs types. |
Teresa Charlin | 0434df6 | 2019-06-06 13:40:35 +0100 | [diff] [blame] | 1172 | std::array<DataType,3> supportedTypes = |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1173 | { |
| 1174 | DataType::Float32, |
Teresa Charlin | 0434df6 | 2019-06-06 13:40:35 +0100 | [diff] [blame] | 1175 | DataType::QuantisedAsymm8, |
| 1176 | DataType::QuantisedSymm16 |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1177 | }; |
| 1178 | |
| 1179 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1180 | "Reference poolind2d: input is not a supported type."); |
| 1181 | |
| 1182 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1183 | "Reference poolind2d: output is not a supported type."); |
| 1184 | |
| 1185 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1186 | "Reference poolind2d: input and output types are mismatched."); |
| 1187 | |
| 1188 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1189 | } |
| 1190 | |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1191 | bool RefLayerSupport::IsQuantizeSupported(const TensorInfo& input, |
| 1192 | const TensorInfo& output, |
| 1193 | Optional<std::string&> reasonIfUnsupported) const |
| 1194 | { |
| 1195 | bool supported = true; |
| 1196 | |
| 1197 | // Define supported output types. |
| 1198 | std::array<DataType,2> supportedInputTypes = { |
| 1199 | DataType::Float32, |
| 1200 | }; |
| 1201 | |
| 1202 | supported &= CheckSupportRule(TypeAnyOf(input, supportedInputTypes), reasonIfUnsupported, |
| 1203 | "Reference quantize: input type not supported."); |
| 1204 | |
| 1205 | // Define supported output types. |
| 1206 | std::array<DataType,2> supportedOutputTypes = { |
| 1207 | DataType::QuantisedAsymm8, |
| 1208 | DataType::QuantisedSymm16 |
| 1209 | }; |
| 1210 | supported &= CheckSupportRule(TypeAnyOf(output, supportedOutputTypes), reasonIfUnsupported, |
| 1211 | "Reference quantize: output type not supported."); |
| 1212 | |
| 1213 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1214 | "Reference quantize: input and output shapes have different num total elements."); |
| 1215 | |
| 1216 | return supported; |
| 1217 | } |
| 1218 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1219 | bool RefLayerSupport::IsReshapeSupported(const TensorInfo& input, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1220 | const ReshapeDescriptor& descriptor, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1221 | Optional<std::string&> reasonIfUnsupported) const |
| 1222 | { |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1223 | ignore_unused(descriptor); |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1224 | // Define supported output types. |
Nina Drozd | 8ed4b8c | 2019-05-29 10:41:04 +0100 | [diff] [blame] | 1225 | std::array<DataType,4> supportedOutputTypes = |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1226 | { |
| 1227 | DataType::Float32, |
| 1228 | DataType::Float16, |
Nina Drozd | 8ed4b8c | 2019-05-29 10:41:04 +0100 | [diff] [blame] | 1229 | DataType::QuantisedAsymm8, |
| 1230 | DataType::QuantisedSymm16 |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1231 | }; |
| 1232 | return CheckSupportRule(TypeAnyOf(input, supportedOutputTypes), reasonIfUnsupported, |
| 1233 | "Reference reshape: input type not supported."); |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1234 | } |
| 1235 | |
| 1236 | bool RefLayerSupport::IsResizeBilinearSupported(const TensorInfo& input, |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame] | 1237 | const TensorInfo& output, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1238 | Optional<std::string&> reasonIfUnsupported) const |
| 1239 | { |
Ellen Norris-Thompson | 3cb85f3 | 2019-06-17 11:32:49 +0100 | [diff] [blame] | 1240 | bool supported = true; |
| 1241 | std::array<DataType,3> supportedTypes = |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame^] | 1242 | { |
| 1243 | DataType::Float32, |
| 1244 | DataType::QuantisedAsymm8, |
| 1245 | DataType::QuantisedSymm16 |
| 1246 | }; |
Ellen Norris-Thompson | 3cb85f3 | 2019-06-17 11:32:49 +0100 | [diff] [blame] | 1247 | |
| 1248 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1249 | "Reference ResizeBilinear: input type not supported"); |
| 1250 | |
| 1251 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1252 | "Reference ResizeBilinear: output type not supported"); |
| 1253 | |
| 1254 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1255 | "Reference ResizeBilinear: input and output types not matching"); |
| 1256 | |
| 1257 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1258 | } |
| 1259 | |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame^] | 1260 | bool RefLayerSupport::IsResizeSupported(const TensorInfo& input, |
| 1261 | const TensorInfo& output, |
| 1262 | const ResizeDescriptor& descriptor, |
| 1263 | Optional<std::string&> reasonIfUnsupported) const |
| 1264 | { |
| 1265 | bool supported = true; |
| 1266 | std::array<DataType,3> supportedTypes = |
| 1267 | { |
| 1268 | DataType::Float32, |
| 1269 | DataType::QuantisedAsymm8, |
| 1270 | DataType::QuantisedSymm16 |
| 1271 | }; |
| 1272 | |
| 1273 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1274 | "Reference Resize: input type not supported"); |
| 1275 | |
| 1276 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1277 | "Reference Resize: output type not supported"); |
| 1278 | |
| 1279 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1280 | "Reference Resize: input and output types not matching"); |
| 1281 | |
| 1282 | return supported; |
| 1283 | } |
| 1284 | |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 1285 | bool RefLayerSupport::IsRsqrtSupported(const TensorInfo& input, |
| 1286 | const TensorInfo& output, |
| 1287 | Optional<std::string&> reasonIfUnsupported) const |
| 1288 | { |
nikraj01 | 0421e7f | 2019-06-14 09:40:34 +0100 | [diff] [blame] | 1289 | bool supported = true; |
nikraj01 | 24d7321 | 2019-06-14 14:20:40 +0100 | [diff] [blame] | 1290 | std::array<DataType,3> supportedTypes = |
nikraj01 | 0421e7f | 2019-06-14 09:40:34 +0100 | [diff] [blame] | 1291 | { |
| 1292 | DataType::Float32, |
nikraj01 | 24d7321 | 2019-06-14 14:20:40 +0100 | [diff] [blame] | 1293 | DataType::QuantisedAsymm8, |
| 1294 | DataType::QuantisedSymm16 |
nikraj01 | 0421e7f | 2019-06-14 09:40:34 +0100 | [diff] [blame] | 1295 | }; |
| 1296 | |
| 1297 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1298 | "Reference rsqrt: input type not supported"); |
| 1299 | |
| 1300 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1301 | "Reference rsqrt: output type not supported"); |
| 1302 | |
| 1303 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1304 | "Reference rsqrt: input and output types not matching"); |
| 1305 | |
| 1306 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1307 | "Reference Rsqrt: input and output shapes have different number of total elements"); |
| 1308 | |
| 1309 | return supported; |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 1310 | } |
| 1311 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1312 | bool RefLayerSupport::IsSoftmaxSupported(const TensorInfo& input, |
| 1313 | const TensorInfo& output, |
| 1314 | const SoftmaxDescriptor& descriptor, |
| 1315 | Optional<std::string&> reasonIfUnsupported) const |
| 1316 | { |
| 1317 | ignore_unused(output); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1318 | bool supported = true; |
| 1319 | std::array<DataType,3> supportedTypes = |
| 1320 | { |
| 1321 | DataType::Float32, |
| 1322 | DataType::QuantisedAsymm8, |
| 1323 | DataType::QuantisedSymm16 |
| 1324 | }; |
| 1325 | |
| 1326 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1327 | "Reference concatenation: output type not supported"); |
| 1328 | |
| 1329 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1330 | "Reference concatenation: input type not supported"); |
| 1331 | |
| 1332 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1333 | "Reference concatenation: input type not supported"); |
| 1334 | |
| 1335 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1336 | } |
| 1337 | |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 1338 | bool RefLayerSupport::IsSpaceToBatchNdSupported(const TensorInfo& input, |
| 1339 | const TensorInfo& output, |
| 1340 | const SpaceToBatchNdDescriptor& descriptor, |
| 1341 | Optional<std::string&> reasonIfUnsupported) const |
| 1342 | { |
| 1343 | ignore_unused(output); |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 1344 | bool supported = true; |
| 1345 | std::array<DataType,3> supportedTypes = |
| 1346 | { |
| 1347 | DataType::Float32, |
| 1348 | DataType::QuantisedAsymm8, |
| 1349 | DataType::QuantisedSymm16 |
| 1350 | }; |
| 1351 | |
| 1352 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1353 | "Reference SpaceToBatchNd: input type not supported"); |
| 1354 | |
| 1355 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1356 | "Reference SpaceToBatchNd: output type not supported"); |
| 1357 | |
| 1358 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1359 | "Reference SpaceToBatchNd: input and output types are mismatched"); |
| 1360 | |
| 1361 | return supported; |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 1362 | } |
| 1363 | |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1364 | bool RefLayerSupport::IsSpaceToDepthSupported(const TensorInfo& input, |
Keith Davis | 5191033 | 2019-06-26 15:28:43 +0100 | [diff] [blame] | 1365 | const TensorInfo& output, |
| 1366 | const SpaceToDepthDescriptor& descriptor, |
| 1367 | Optional<std::string&> reasonIfUnsupported) const |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1368 | { |
| 1369 | |
| 1370 | ignore_unused(descriptor); |
| 1371 | bool supported = true; |
| 1372 | |
| 1373 | std::array<DataType,2> supportedTypes = |
| 1374 | { |
| 1375 | DataType::Float32, |
| 1376 | DataType::QuantisedAsymm8, |
| 1377 | }; |
| 1378 | |
| 1379 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1380 | "Reference SpaceToDepth: input type not supported"); |
| 1381 | |
| 1382 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1383 | "Reference SpaceToDepth: output type not supported"); |
| 1384 | |
| 1385 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1386 | "Reference SpaceToDepth: input and output types are mismatched"); |
| 1387 | |
| 1388 | return supported; |
| 1389 | } |
| 1390 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1391 | bool RefLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 1392 | const ViewsDescriptor& descriptor, |
| 1393 | Optional<std::string&> reasonIfUnsupported) const |
| 1394 | { |
| 1395 | ignore_unused(descriptor); |
| 1396 | return IsSupportedForDataTypeRef(reasonIfUnsupported, |
| 1397 | input.GetDataType(), |
| 1398 | &TrueFunc<>, |
| 1399 | &TrueFunc<>); |
| 1400 | } |
| 1401 | |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 1402 | bool RefLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 1403 | const std::vector<std::reference_wrapper<TensorInfo>>& outputs, |
| 1404 | const ViewsDescriptor& descriptor, |
| 1405 | Optional<std::string&> reasonIfUnsupported) const |
| 1406 | { |
| 1407 | ignore_unused(descriptor); |
| 1408 | ignore_unused(outputs); |
| 1409 | return IsSupportedForDataTypeRef(reasonIfUnsupported, |
| 1410 | input.GetDataType(), |
| 1411 | &TrueFunc<>, |
| 1412 | &TrueFunc<>); |
| 1413 | } |
| 1414 | |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 1415 | bool RefLayerSupport::IsStridedSliceSupported(const TensorInfo& input, |
| 1416 | const TensorInfo& output, |
| 1417 | const StridedSliceDescriptor& descriptor, |
| 1418 | Optional<std::string&> reasonIfUnsupported) const |
| 1419 | { |
| 1420 | ignore_unused(output); |
| 1421 | ignore_unused(descriptor); |
| 1422 | return IsSupportedForDataTypeRef(reasonIfUnsupported, |
| 1423 | input.GetDataType(), |
| 1424 | &TrueFunc<>, |
| 1425 | &TrueFunc<>); |
| 1426 | } |
| 1427 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1428 | bool RefLayerSupport::IsSubtractionSupported(const TensorInfo& input0, |
| 1429 | const TensorInfo& input1, |
| 1430 | const TensorInfo& output, |
| 1431 | Optional<std::string&> reasonIfUnsupported) const |
| 1432 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1433 | bool supported = true; |
| 1434 | |
| 1435 | std::array<DataType,3> supportedTypes = { |
| 1436 | DataType::Float32, |
| 1437 | DataType::QuantisedAsymm8, |
| 1438 | DataType::QuantisedSymm16 |
| 1439 | }; |
| 1440 | |
| 1441 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1442 | "Reference subtraction: input 0 is not a supported type."); |
| 1443 | |
| 1444 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1445 | "Reference subtraction: input 1 is not a supported type."); |
| 1446 | |
| 1447 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1448 | "Reference subtraction: output is not a supported type."); |
| 1449 | |
| 1450 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1451 | "Reference subtraction: input 0 and Input 1 types are mismatched"); |
| 1452 | |
| 1453 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1454 | "Reference subtraction: input and output types are mismatched"); |
| 1455 | |
| 1456 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1457 | "Reference subtraction: shapes are not suitable for implicit broadcast."); |
| 1458 | |
| 1459 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1460 | } |
| 1461 | |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 1462 | bool RefLayerSupport::IsPreluSupported(const TensorInfo& input, |
| 1463 | const TensorInfo& alpha, |
| 1464 | const TensorInfo& output, |
| 1465 | Optional<std::string&> reasonIfUnsupported) const |
| 1466 | { |
| 1467 | bool supported = true; |
| 1468 | |
| 1469 | std::array<DataType, 3> supportedTypes |
| 1470 | { |
| 1471 | DataType::Float32, |
| 1472 | DataType::QuantisedAsymm8, |
| 1473 | DataType::QuantisedSymm16 |
| 1474 | }; |
| 1475 | |
| 1476 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1477 | "PReLU: input is not a supported type."); |
| 1478 | |
| 1479 | supported &= CheckSupportRule(TypeAnyOf(alpha, supportedTypes), reasonIfUnsupported, |
| 1480 | "PReLU: alpha is not a supported type."); |
| 1481 | |
| 1482 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1483 | "PReLU: output is not a supported type."); |
| 1484 | |
| 1485 | supported &= CheckSupportRule(TypesAreEqual(input, alpha, output), reasonIfUnsupported, |
| 1486 | "PReLU: input, alpha and output types are mismatched"); |
| 1487 | |
| 1488 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input, alpha, output), reasonIfUnsupported, |
| 1489 | "PReLU: shapes are not suitable for implicit broadcast"); |
| 1490 | |
| 1491 | return supported; |
| 1492 | } |
| 1493 | |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1494 | bool RefLayerSupport::IsTransposeConvolution2dSupported(const TensorInfo& input, |
| 1495 | const TensorInfo& output, |
| 1496 | const TransposeConvolution2dDescriptor& descriptor, |
| 1497 | const TensorInfo& weights, |
| 1498 | const Optional<TensorInfo>& biases, |
| 1499 | Optional<std::string&> reasonIfUnsupported) const |
| 1500 | { |
| 1501 | ignore_unused(descriptor); |
| 1502 | |
| 1503 | bool supported = true; |
| 1504 | |
| 1505 | std::array<DataType,3> supportedTypes = |
| 1506 | { |
| 1507 | DataType::Float32, |
| 1508 | DataType::QuantisedAsymm8, |
| 1509 | DataType::QuantisedSymm16 |
| 1510 | }; |
| 1511 | |
| 1512 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1513 | "Reference TransposeConvolution2d: input is not a supported type."); |
| 1514 | |
| 1515 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1516 | "Reference TransposeConvolution2d: output is not a supported type."); |
| 1517 | |
| 1518 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 1519 | "Reference TransposeConvolution2d: weights is not a supported type."); |
| 1520 | |
| 1521 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1522 | "Reference TransposeConvolution2d: input and output types mismatched."); |
| 1523 | |
| 1524 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 1525 | "Reference TransposeConvolution2d: input and weights types mismatched."); |
| 1526 | |
| 1527 | if (biases.has_value()) |
| 1528 | { |
| 1529 | std::array<DataType,3> biasesSupportedTypes = { |
| 1530 | DataType::Float32, |
| 1531 | DataType::Signed32 |
| 1532 | }; |
| 1533 | supported &= CheckSupportRule(TypeAnyOf(biases.value(), biasesSupportedTypes), reasonIfUnsupported, |
| 1534 | "Reference TransposeConvolution2d: biases is not a supported type."); |
| 1535 | } |
| 1536 | |
| 1537 | return supported; |
| 1538 | } |
| 1539 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1540 | } // namespace armnn |