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