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