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