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