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 | |
Kevin May | 09ca49c | 2019-10-09 12:37:34 +0100 | [diff] [blame] | 836 | bool RefLayerSupport::IsInstanceNormalizationSupported(const TensorInfo& input, |
| 837 | const TensorInfo& output, |
| 838 | const InstanceNormalizationDescriptor& descriptor, |
| 839 | Optional<std::string&> reasonIfUnsupported) const |
| 840 | { |
| 841 | ignore_unused(descriptor); |
| 842 | // Define supported types |
| 843 | std::array<DataType, 4> supportedTypes = |
| 844 | { |
| 845 | DataType::Float32, |
| 846 | DataType::Float16 |
| 847 | }; |
| 848 | |
| 849 | bool supported = true; |
| 850 | |
| 851 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 852 | "Reference Instance Normalization: input type not supported."); |
| 853 | |
| 854 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 855 | "Reference Instance Normalization: output type not supported."); |
| 856 | |
| 857 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 858 | "Reference Instance Normalization: input and output types mismatched."); |
| 859 | |
| 860 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 861 | "Reference Instance Normalization: input and output shapes have different " |
| 862 | "num total elements."); |
| 863 | |
| 864 | return supported; |
| 865 | } |
| 866 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 867 | bool RefLayerSupport::IsL2NormalizationSupported(const TensorInfo& input, |
| 868 | const TensorInfo& output, |
| 869 | const L2NormalizationDescriptor& descriptor, |
| 870 | Optional<std::string&> reasonIfUnsupported) const |
| 871 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 872 | ignore_unused(descriptor); |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 873 | // Define supported types |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 874 | std::array<DataType, 4> supportedTypes = |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 875 | { |
| 876 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 877 | DataType::Float16, |
Ferran Balaguer | c6138d8 | 2019-06-13 17:23:50 +0100 | [diff] [blame] | 878 | DataType::QuantisedAsymm8, |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 879 | DataType::QuantisedSymm16 |
| 880 | }; |
| 881 | |
| 882 | bool supported = true; |
| 883 | |
| 884 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 885 | "Reference L2normalization: input type not supported."); |
| 886 | |
| 887 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 888 | "Reference L2normalization: output type not supported."); |
| 889 | |
| 890 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 891 | "Reference L2normalization: input and output types mismatched."); |
| 892 | |
| 893 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 894 | "Reference L2normalization: input and output shapes have different " |
| 895 | "num total elements."); |
| 896 | |
| 897 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 898 | } |
| 899 | |
| 900 | bool RefLayerSupport::IsLstmSupported(const TensorInfo& input, |
| 901 | const TensorInfo& outputStateIn, |
| 902 | const TensorInfo& cellStateIn, |
| 903 | const TensorInfo& scratchBuffer, |
| 904 | const TensorInfo& outputStateOut, |
| 905 | const TensorInfo& cellStateOut, |
| 906 | const TensorInfo& output, |
| 907 | const LstmDescriptor& descriptor, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 908 | const LstmInputParamsInfo& paramsInfo, |
| 909 | Optional<std::string&> reasonIfUnsupported) const |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 910 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 911 | ignore_unused(descriptor); |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 912 | ignore_unused(paramsInfo); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 913 | |
| 914 | bool supported = true; |
| 915 | |
| 916 | std::array<DataType,2> supportedTypes = { |
Conor Kennedy | b9971c9 | 2019-05-07 07:14:23 +0100 | [diff] [blame] | 917 | DataType::Float32, |
| 918 | DataType::QuantisedSymm16 |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 919 | }; |
| 920 | |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 921 | // check inputs and outputs |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 922 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 923 | "Reference Lstm: input is not a supported type."); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 924 | supported &= CheckSupportRule(TypesAreEqual(input, outputStateIn), reasonIfUnsupported, |
| 925 | "Reference Lstm: input and outputStateIn types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 926 | supported &= CheckSupportRule(TypesAreEqual(input, cellStateIn), reasonIfUnsupported, |
| 927 | "Reference Lstm: input and cellStateIn types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 928 | supported &= CheckSupportRule(TypesAreEqual(input, scratchBuffer), reasonIfUnsupported, |
| 929 | "Reference Lstm: input and scratchBuffer types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 930 | supported &= CheckSupportRule(TypesAreEqual(input, outputStateOut), reasonIfUnsupported, |
| 931 | "Reference Lstm: input and outputStateOut types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 932 | supported &= CheckSupportRule(TypesAreEqual(input, cellStateOut), reasonIfUnsupported, |
| 933 | "Reference Lstm: input and cellStateOut types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 934 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 935 | "Reference Lstm: input and output types are mismatched"); |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 936 | // check layer parameters |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 937 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToForgetWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 938 | "Reference Lstm: input and InputToForgetWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 939 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToCellWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 940 | "Reference Lstm: input and InputToCellWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 941 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToOutputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 942 | "Reference Lstm: input and InputToOutputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 943 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToForgetWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 944 | "Reference Lstm: input and RecurrentToForgetWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 945 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToCellWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 946 | "Reference Lstm: input and RecurrentToCellWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 947 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToOutputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 948 | "Reference Lstm: input and RecurrentToOutputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 949 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetForgetGateBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 950 | "Reference Lstm: input and ForgetGateBias types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 951 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 952 | "Reference Lstm: input and CellBias types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 953 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetOutputGateBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 954 | "Reference Lstm: input and OutputGateBias types are mismatched"); |
| 955 | if (!descriptor.m_CifgEnabled) |
| 956 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 957 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToInputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 958 | "Reference Lstm: input and InputToInputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 959 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToInputWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 960 | reasonIfUnsupported, |
| 961 | "Reference Lstm: input and RecurrentToInputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 962 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputGateBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 963 | "Reference Lstm: input and InputGateBias types are mismatched"); |
| 964 | if (descriptor.m_PeepholeEnabled) |
| 965 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 966 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellToInputWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 967 | reasonIfUnsupported, |
| 968 | "Reference Lstm: input and CellToInputWeights types are mismatched"); |
| 969 | } |
| 970 | } |
| 971 | if (descriptor.m_PeepholeEnabled) |
| 972 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 973 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellToForgetWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 974 | "Reference Lstm: input and CellToForgetWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 975 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellToOutputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 976 | "Reference Lstm: input and CellToOutputWeights types are mismatched"); |
| 977 | } |
| 978 | if (descriptor.m_ProjectionEnabled) |
| 979 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 980 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetProjectionWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 981 | "Reference Lstm: input and mProjectionWeights types are mismatched"); |
| 982 | if (paramsInfo.m_ProjectionBias != nullptr) |
| 983 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 984 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetProjectionBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 985 | "Reference Lstm: input and ProjectionBias types are mismatched"); |
| 986 | } |
| 987 | } |
| 988 | if (descriptor.m_LayerNormEnabled) |
| 989 | { |
| 990 | if (!descriptor.m_CifgEnabled) |
| 991 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 992 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 993 | reasonIfUnsupported, |
| 994 | "Reference Lstm: input and InputLayerNormWeights types are mismatched"); |
| 995 | } |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 996 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetForgetLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 997 | reasonIfUnsupported, |
| 998 | "Reference Lstm: input and ForgetLayerNormWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 999 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1000 | reasonIfUnsupported, |
| 1001 | "Reference Lstm: input and CellLayerNormWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1002 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetOutputLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1003 | reasonIfUnsupported, |
| 1004 | "Reference Lstm: input and OutputLayerNormWeights types are mismatched"); |
| 1005 | } |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1006 | |
| 1007 | return supported; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1008 | } |
| 1009 | |
saoste01 | 2df12b3 | 2018-11-28 16:57:20 +0000 | [diff] [blame] | 1010 | bool RefLayerSupport::IsMaximumSupported(const TensorInfo& input0, |
| 1011 | const TensorInfo& input1, |
| 1012 | const TensorInfo& output, |
| 1013 | Optional<std::string&> reasonIfUnsupported) const |
| 1014 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1015 | bool supported = true; |
| 1016 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1017 | std::array<DataType,4> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1018 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1019 | DataType::Float16, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1020 | DataType::QuantisedAsymm8, |
| 1021 | DataType::QuantisedSymm16 |
| 1022 | }; |
| 1023 | |
| 1024 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1025 | "Reference maximum: input 0 is not a supported type."); |
| 1026 | |
| 1027 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1028 | "Reference maximum: input 1 is not a supported type."); |
| 1029 | |
| 1030 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1031 | "Reference maximum: output is not a supported type."); |
| 1032 | |
| 1033 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1034 | "Reference maximum: input 0 and Input 1 types are mismatched"); |
| 1035 | |
| 1036 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1037 | "Reference maximum: input and output types are mismatched"); |
| 1038 | |
| 1039 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1040 | "Reference maximum: shapes are not suitable for implicit broadcast."); |
| 1041 | |
| 1042 | return supported; |
saoste01 | 2df12b3 | 2018-11-28 16:57:20 +0000 | [diff] [blame] | 1043 | } |
| 1044 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1045 | bool RefLayerSupport::IsMeanSupported(const TensorInfo& input, |
| 1046 | const TensorInfo& output, |
| 1047 | const MeanDescriptor& descriptor, |
| 1048 | Optional<std::string&> reasonIfUnsupported) const |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 1049 | { |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1050 | bool supported = true; |
| 1051 | std::string meanLayerStr = "Mean"; |
| 1052 | std::string outputTensorStr = "output"; |
| 1053 | |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1054 | std::array<DataType,4> supportedTypes = |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1055 | { |
| 1056 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1057 | DataType::Float16, |
James Conroy | b80775f | 2019-06-11 11:25:30 +0100 | [diff] [blame] | 1058 | DataType::QuantisedAsymm8, |
| 1059 | DataType::QuantisedSymm16 |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1060 | }; |
| 1061 | |
| 1062 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1063 | "Reference Mean: input type not supported."); |
| 1064 | |
| 1065 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1066 | "Reference Mean: input and output types are mismatched"); |
| 1067 | |
| 1068 | if (descriptor.m_KeepDims) |
| 1069 | { |
| 1070 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, input.GetNumDimensions()), |
| 1071 | reasonIfUnsupported, |
| 1072 | CreateIncorrectDimensionsErrorMsg(input.GetNumDimensions(), |
| 1073 | output.GetNumDimensions(), |
| 1074 | meanLayerStr, outputTensorStr).data()); |
| 1075 | } |
| 1076 | else if (descriptor.m_Axis.empty()) |
| 1077 | { |
| 1078 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, 1), |
| 1079 | reasonIfUnsupported, |
| 1080 | CreateIncorrectDimensionsErrorMsg(1, output.GetNumDimensions(), |
| 1081 | meanLayerStr, outputTensorStr).data()); |
| 1082 | } |
| 1083 | else |
| 1084 | { |
| 1085 | auto outputDim = input.GetNumDimensions() - boost::numeric_cast<unsigned int>(descriptor.m_Axis.size()); |
| 1086 | |
| 1087 | if (outputDim > 0) |
| 1088 | { |
| 1089 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, outputDim), |
| 1090 | reasonIfUnsupported, |
| 1091 | CreateIncorrectDimensionsErrorMsg(outputDim, output.GetNumDimensions(), |
| 1092 | meanLayerStr, outputTensorStr).data()); |
| 1093 | } |
| 1094 | else |
| 1095 | { |
| 1096 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, 1), |
| 1097 | reasonIfUnsupported, |
| 1098 | CreateIncorrectDimensionsErrorMsg(1, output.GetNumDimensions(), |
| 1099 | meanLayerStr, outputTensorStr).data()); |
| 1100 | } |
| 1101 | } |
| 1102 | |
| 1103 | return supported; |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 1104 | } |
| 1105 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1106 | bool RefLayerSupport::IsMergerSupported(const std::vector<const TensorInfo*> inputs, |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 1107 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1108 | const MergerDescriptor& descriptor, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1109 | Optional<std::string&> reasonIfUnsupported) const |
| 1110 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1111 | return IsConcatSupported(inputs, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1112 | } |
| 1113 | |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1114 | bool RefLayerSupport::IsMemCopySupported(const TensorInfo &input, |
| 1115 | const TensorInfo &output, |
| 1116 | Optional<std::string &> reasonIfUnsupported) const |
| 1117 | { |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1118 | bool supported = true; |
| 1119 | |
| 1120 | std::array<DataType,5> supportedTypes = |
| 1121 | { |
| 1122 | DataType::Float32, |
| 1123 | DataType::Float16, |
| 1124 | DataType::QuantisedAsymm8, |
| 1125 | DataType::QuantisedSymm16, |
| 1126 | DataType::Boolean |
| 1127 | }; |
| 1128 | |
| 1129 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1130 | "Reference MemCopy: input type not supported"); |
| 1131 | |
| 1132 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1133 | "Reference MemCopy: output type not supported"); |
| 1134 | |
| 1135 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1136 | "Reference MemCopy: input and output types are mismatched"); |
| 1137 | |
| 1138 | return supported; |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1139 | } |
| 1140 | |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 1141 | bool RefLayerSupport::IsMinimumSupported(const TensorInfo& input0, |
| 1142 | const TensorInfo& input1, |
| 1143 | const TensorInfo& output, |
| 1144 | Optional<std::string&> reasonIfUnsupported) const |
| 1145 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1146 | bool supported = true; |
| 1147 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1148 | std::array<DataType,4> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1149 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1150 | DataType::Float16, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1151 | DataType::QuantisedAsymm8, |
| 1152 | DataType::QuantisedSymm16 |
| 1153 | }; |
| 1154 | |
| 1155 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1156 | "Reference minimum: input 0 is not a supported type."); |
| 1157 | |
| 1158 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1159 | "Reference minimum: input 1 is not a supported type."); |
| 1160 | |
| 1161 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1162 | "Reference minimum: output is not a supported type."); |
| 1163 | |
| 1164 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1165 | "Reference minimum: input 0 and Input 1 types are mismatched"); |
| 1166 | |
| 1167 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1168 | "Reference minimum: input and output types are mismatched"); |
| 1169 | |
| 1170 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1171 | "Reference minimum: shapes are not suitable for implicit broadcast."); |
| 1172 | |
| 1173 | return supported; |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 1174 | } |
| 1175 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1176 | bool RefLayerSupport::IsMultiplicationSupported(const TensorInfo& input0, |
| 1177 | const TensorInfo& input1, |
| 1178 | const TensorInfo& output, |
| 1179 | Optional<std::string&> reasonIfUnsupported) const |
| 1180 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1181 | bool supported = true; |
| 1182 | |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1183 | std::array<DataType,4> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1184 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1185 | DataType::Float16, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1186 | DataType::QuantisedAsymm8, |
| 1187 | DataType::QuantisedSymm16 |
| 1188 | }; |
| 1189 | |
| 1190 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1191 | "Reference multiplication: input 0 is not a supported type."); |
| 1192 | |
| 1193 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1194 | "Reference multiplication: input 1 is not a supported type."); |
| 1195 | |
| 1196 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1197 | "Reference multiplication: output is not a supported type."); |
| 1198 | |
| 1199 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1200 | "Reference multiplication: input 0 and Input 1 types are mismatched"); |
| 1201 | |
| 1202 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1203 | "Reference multiplication: input and output types are mismatched"); |
| 1204 | |
| 1205 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1206 | "Reference multiplication: shapes are not suitable for implicit broadcast."); |
| 1207 | |
| 1208 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1209 | } |
| 1210 | |
| 1211 | bool RefLayerSupport::IsNormalizationSupported(const TensorInfo& input, |
| 1212 | const TensorInfo& output, |
| 1213 | const NormalizationDescriptor& descriptor, |
| 1214 | Optional<std::string&> reasonIfUnsupported) const |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 1215 | { |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 1216 | ignore_unused(descriptor); |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1217 | |
| 1218 | // Define supported types |
Matteo Martincigh | 6aeb771 | 2019-06-05 17:23:29 +0100 | [diff] [blame] | 1219 | std::array<DataType, 4> supportedTypes = |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1220 | { |
| 1221 | DataType::Float16, |
| 1222 | DataType::Float32, |
Matteo Martincigh | 6aeb771 | 2019-06-05 17:23:29 +0100 | [diff] [blame] | 1223 | DataType::QuantisedAsymm8, |
| 1224 | DataType::QuantisedSymm16 |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1225 | }; |
| 1226 | |
| 1227 | bool supported = true; |
| 1228 | |
| 1229 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1230 | "Reference normalization: input type not supported."); |
| 1231 | |
| 1232 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1233 | "Reference normalization: output type not supported."); |
| 1234 | |
| 1235 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1236 | "Reference normalization: input and output shapes have different " |
| 1237 | "num total elements."); |
| 1238 | |
| 1239 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1240 | } |
| 1241 | |
| 1242 | bool RefLayerSupport::IsOutputSupported(const TensorInfo& output, |
| 1243 | Optional<std::string&> reasonIfUnsupported) const |
| 1244 | { |
Narumol Prangnawarat | b6441e4 | 2019-06-04 11:22:00 +0100 | [diff] [blame] | 1245 | return true; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1246 | } |
| 1247 | |
| 1248 | bool RefLayerSupport::IsPadSupported(const TensorInfo& input, |
| 1249 | const TensorInfo& output, |
| 1250 | const PadDescriptor& descriptor, |
| 1251 | Optional<std::string&> reasonIfUnsupported) const |
| 1252 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1253 | ignore_unused(descriptor); |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 1254 | bool supported = true; |
| 1255 | |
| 1256 | // Define supported output and inputs types. |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1257 | std::array<DataType,4> supportedTypes = |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 1258 | { |
| 1259 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1260 | DataType::Float16, |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 1261 | DataType::QuantisedAsymm8, |
| 1262 | DataType::QuantisedSymm16 |
| 1263 | }; |
| 1264 | |
| 1265 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1266 | "Reference pad: input is not a supported type."); |
| 1267 | |
| 1268 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1269 | "Reference pad: output is not a supported type."); |
| 1270 | |
| 1271 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1272 | "Reference pad: input and output types are mismatched."); |
| 1273 | |
| 1274 | return supported; |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 1275 | } |
| 1276 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1277 | bool RefLayerSupport::IsPermuteSupported(const TensorInfo& input, |
| 1278 | const TensorInfo& output, |
| 1279 | const PermuteDescriptor& descriptor, |
| 1280 | Optional<std::string&> reasonIfUnsupported) const |
| 1281 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1282 | ignore_unused(descriptor); |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 1283 | bool supported = true; |
| 1284 | |
| 1285 | // Define supported output and inputs types. |
| 1286 | std::array<DataType,3> supportedTypes = |
| 1287 | { |
| 1288 | DataType::Float32, |
| 1289 | DataType::QuantisedAsymm8, |
| 1290 | DataType::QuantisedSymm16 |
| 1291 | }; |
| 1292 | |
| 1293 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1294 | "Reference permute: input is not a supported type."); |
| 1295 | |
| 1296 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1297 | "Reference permute: output is not a supported type."); |
| 1298 | |
| 1299 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1300 | "Reference permute: input and output types are mismatched."); |
| 1301 | |
| 1302 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1303 | } |
| 1304 | |
| 1305 | bool RefLayerSupport::IsPooling2dSupported(const TensorInfo& input, |
| 1306 | const TensorInfo& output, |
| 1307 | const Pooling2dDescriptor& descriptor, |
| 1308 | Optional<std::string&> reasonIfUnsupported) const |
| 1309 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1310 | ignore_unused(descriptor); |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1311 | bool supported = true; |
| 1312 | |
| 1313 | // Define supported output and inputs types. |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1314 | std::array<DataType,4> supportedTypes = |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1315 | { |
| 1316 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1317 | DataType::Float16, |
Teresa Charlin | 0434df6 | 2019-06-06 13:40:35 +0100 | [diff] [blame] | 1318 | DataType::QuantisedAsymm8, |
| 1319 | DataType::QuantisedSymm16 |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1320 | }; |
| 1321 | |
| 1322 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1323 | "Reference poolind2d: input is not a supported type."); |
| 1324 | |
| 1325 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1326 | "Reference poolind2d: output is not a supported type."); |
| 1327 | |
| 1328 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1329 | "Reference poolind2d: input and output types are mismatched."); |
| 1330 | |
| 1331 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1332 | } |
| 1333 | |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1334 | bool RefLayerSupport::IsQuantizeSupported(const TensorInfo& input, |
| 1335 | const TensorInfo& output, |
| 1336 | Optional<std::string&> reasonIfUnsupported) const |
| 1337 | { |
| 1338 | bool supported = true; |
| 1339 | |
| 1340 | // Define supported output types. |
Sadik Armagan | 1a81630 | 2019-07-29 17:16:40 +0100 | [diff] [blame] | 1341 | std::array<DataType,1> supportedInputTypes = { |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1342 | DataType::Float32, |
| 1343 | }; |
| 1344 | |
| 1345 | supported &= CheckSupportRule(TypeAnyOf(input, supportedInputTypes), reasonIfUnsupported, |
| 1346 | "Reference quantize: input type not supported."); |
| 1347 | |
| 1348 | // Define supported output types. |
| 1349 | std::array<DataType,2> supportedOutputTypes = { |
| 1350 | DataType::QuantisedAsymm8, |
| 1351 | DataType::QuantisedSymm16 |
| 1352 | }; |
| 1353 | supported &= CheckSupportRule(TypeAnyOf(output, supportedOutputTypes), reasonIfUnsupported, |
| 1354 | "Reference quantize: output type not supported."); |
| 1355 | |
| 1356 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1357 | "Reference quantize: input and output shapes have different num total elements."); |
| 1358 | |
| 1359 | return supported; |
| 1360 | } |
| 1361 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1362 | bool RefLayerSupport::IsReshapeSupported(const TensorInfo& input, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1363 | const ReshapeDescriptor& descriptor, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1364 | Optional<std::string&> reasonIfUnsupported) const |
| 1365 | { |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1366 | ignore_unused(descriptor); |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1367 | // Define supported output types. |
Narumol Prangnawarat | 0718ee9 | 2019-09-13 16:53:38 +0100 | [diff] [blame] | 1368 | std::array<DataType,5> supportedOutputTypes = |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1369 | { |
| 1370 | DataType::Float32, |
| 1371 | DataType::Float16, |
Narumol Prangnawarat | 0718ee9 | 2019-09-13 16:53:38 +0100 | [diff] [blame] | 1372 | DataType::Signed32, |
Nina Drozd | 8ed4b8c | 2019-05-29 10:41:04 +0100 | [diff] [blame] | 1373 | DataType::QuantisedAsymm8, |
| 1374 | DataType::QuantisedSymm16 |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1375 | }; |
| 1376 | return CheckSupportRule(TypeAnyOf(input, supportedOutputTypes), reasonIfUnsupported, |
| 1377 | "Reference reshape: input type not supported."); |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1378 | } |
| 1379 | |
| 1380 | bool RefLayerSupport::IsResizeBilinearSupported(const TensorInfo& input, |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame] | 1381 | const TensorInfo& output, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1382 | Optional<std::string&> reasonIfUnsupported) const |
| 1383 | { |
Ellen Norris-Thompson | 3cb85f3 | 2019-06-17 11:32:49 +0100 | [diff] [blame] | 1384 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1385 | std::array<DataType,4> supportedTypes = |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1386 | { |
| 1387 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1388 | DataType::Float16, |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1389 | DataType::QuantisedAsymm8, |
| 1390 | DataType::QuantisedSymm16 |
| 1391 | }; |
Ellen Norris-Thompson | 3cb85f3 | 2019-06-17 11:32:49 +0100 | [diff] [blame] | 1392 | |
| 1393 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1394 | "Reference ResizeBilinear: input type not supported"); |
| 1395 | |
| 1396 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1397 | "Reference ResizeBilinear: output type not supported"); |
| 1398 | |
| 1399 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1400 | "Reference ResizeBilinear: input and output types not matching"); |
| 1401 | |
| 1402 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1403 | } |
| 1404 | |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1405 | bool RefLayerSupport::IsResizeSupported(const TensorInfo& input, |
| 1406 | const TensorInfo& output, |
| 1407 | const ResizeDescriptor& descriptor, |
| 1408 | Optional<std::string&> reasonIfUnsupported) const |
| 1409 | { |
| 1410 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1411 | std::array<DataType,4> supportedTypes = |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1412 | { |
| 1413 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1414 | DataType::Float16, |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1415 | DataType::QuantisedAsymm8, |
| 1416 | DataType::QuantisedSymm16 |
| 1417 | }; |
| 1418 | |
| 1419 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1420 | "Reference Resize: input type not supported"); |
| 1421 | |
| 1422 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1423 | "Reference Resize: output type not supported"); |
| 1424 | |
| 1425 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1426 | "Reference Resize: input and output types not matching"); |
| 1427 | |
| 1428 | return supported; |
| 1429 | } |
| 1430 | |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 1431 | bool RefLayerSupport::IsRsqrtSupported(const TensorInfo& input, |
| 1432 | const TensorInfo& output, |
| 1433 | Optional<std::string&> reasonIfUnsupported) const |
| 1434 | { |
nikraj01 | 0421e7f | 2019-06-14 09:40:34 +0100 | [diff] [blame] | 1435 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1436 | std::array<DataType,4> supportedTypes = |
nikraj01 | 0421e7f | 2019-06-14 09:40:34 +0100 | [diff] [blame] | 1437 | { |
| 1438 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1439 | DataType::Float16, |
nikraj01 | 24d7321 | 2019-06-14 14:20:40 +0100 | [diff] [blame] | 1440 | DataType::QuantisedAsymm8, |
| 1441 | DataType::QuantisedSymm16 |
nikraj01 | 0421e7f | 2019-06-14 09:40:34 +0100 | [diff] [blame] | 1442 | }; |
| 1443 | |
| 1444 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1445 | "Reference rsqrt: input type not supported"); |
| 1446 | |
| 1447 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1448 | "Reference rsqrt: output type not supported"); |
| 1449 | |
| 1450 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1451 | "Reference rsqrt: input and output types not matching"); |
| 1452 | |
| 1453 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1454 | "Reference Rsqrt: input and output shapes have different number of total elements"); |
| 1455 | |
| 1456 | return supported; |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 1457 | } |
| 1458 | |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 1459 | bool RefLayerSupport::IsSliceSupported(const TensorInfo& input, |
| 1460 | const TensorInfo& output, |
| 1461 | const SliceDescriptor& descriptor, |
| 1462 | Optional<std::string&> reasonIfUnsupported) const |
| 1463 | { |
| 1464 | ignore_unused(descriptor); |
| 1465 | bool supported = true; |
| 1466 | |
| 1467 | std::array<DataType, 3> supportedTypes = |
| 1468 | { |
| 1469 | DataType::Float32, |
| 1470 | DataType::QuantisedAsymm8, |
| 1471 | DataType::QuantisedSymm16 |
| 1472 | }; |
| 1473 | |
| 1474 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1475 | "Reference Slice: input type not supported"); |
| 1476 | |
| 1477 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1478 | "Reference Slice: output type not supported"); |
| 1479 | |
| 1480 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1481 | "Reference Slice: input and output types are mismatched"); |
| 1482 | |
| 1483 | return supported; |
| 1484 | } |
| 1485 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1486 | bool RefLayerSupport::IsSoftmaxSupported(const TensorInfo& input, |
| 1487 | const TensorInfo& output, |
| 1488 | const SoftmaxDescriptor& descriptor, |
| 1489 | Optional<std::string&> reasonIfUnsupported) const |
| 1490 | { |
| 1491 | ignore_unused(output); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1492 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1493 | std::array<DataType,4> supportedTypes = |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1494 | { |
| 1495 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1496 | DataType::Float16, |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1497 | DataType::QuantisedAsymm8, |
| 1498 | DataType::QuantisedSymm16 |
| 1499 | }; |
| 1500 | |
| 1501 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1502 | "Reference concatenation: output type not supported"); |
| 1503 | |
| 1504 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1505 | "Reference concatenation: input type not supported"); |
| 1506 | |
| 1507 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1508 | "Reference concatenation: input type not supported"); |
| 1509 | |
| 1510 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1511 | } |
| 1512 | |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 1513 | bool RefLayerSupport::IsSpaceToBatchNdSupported(const TensorInfo& input, |
| 1514 | const TensorInfo& output, |
| 1515 | const SpaceToBatchNdDescriptor& descriptor, |
| 1516 | Optional<std::string&> reasonIfUnsupported) const |
| 1517 | { |
| 1518 | ignore_unused(output); |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 1519 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1520 | std::array<DataType,4> supportedTypes = |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 1521 | { |
| 1522 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1523 | DataType::Float16, |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 1524 | DataType::QuantisedAsymm8, |
| 1525 | DataType::QuantisedSymm16 |
| 1526 | }; |
| 1527 | |
| 1528 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1529 | "Reference SpaceToBatchNd: input type not supported"); |
| 1530 | |
| 1531 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1532 | "Reference SpaceToBatchNd: output type not supported"); |
| 1533 | |
| 1534 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1535 | "Reference SpaceToBatchNd: input and output types are mismatched"); |
| 1536 | |
| 1537 | return supported; |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 1538 | } |
| 1539 | |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1540 | bool RefLayerSupport::IsSpaceToDepthSupported(const TensorInfo& input, |
Keith Davis | 5191033 | 2019-06-26 15:28:43 +0100 | [diff] [blame] | 1541 | const TensorInfo& output, |
| 1542 | const SpaceToDepthDescriptor& descriptor, |
| 1543 | Optional<std::string&> reasonIfUnsupported) const |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1544 | { |
| 1545 | |
| 1546 | ignore_unused(descriptor); |
| 1547 | bool supported = true; |
| 1548 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1549 | std::array<DataType,4> supportedTypes = |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1550 | { |
| 1551 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1552 | DataType::Float16, |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1553 | DataType::QuantisedAsymm8, |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 1554 | DataType::QuantisedSymm16 |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1555 | }; |
| 1556 | |
| 1557 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1558 | "Reference SpaceToDepth: input type not supported"); |
| 1559 | |
| 1560 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1561 | "Reference SpaceToDepth: output type not supported"); |
| 1562 | |
| 1563 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1564 | "Reference SpaceToDepth: input and output types are mismatched"); |
| 1565 | |
| 1566 | return supported; |
| 1567 | } |
| 1568 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1569 | bool RefLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 1570 | const ViewsDescriptor& descriptor, |
| 1571 | Optional<std::string&> reasonIfUnsupported) const |
| 1572 | { |
| 1573 | ignore_unused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1574 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1575 | std::array<DataType,4> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1576 | { |
| 1577 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1578 | DataType::Float16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1579 | DataType::QuantisedAsymm8, |
| 1580 | DataType::QuantisedSymm16 |
| 1581 | }; |
| 1582 | |
| 1583 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1584 | "Reference splitter: input type not supported"); |
| 1585 | |
| 1586 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1587 | } |
| 1588 | |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 1589 | bool RefLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 1590 | const std::vector<std::reference_wrapper<TensorInfo>>& outputs, |
| 1591 | const ViewsDescriptor& descriptor, |
| 1592 | Optional<std::string&> reasonIfUnsupported) const |
| 1593 | { |
| 1594 | ignore_unused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1595 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1596 | std::array<DataType,4> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1597 | { |
| 1598 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1599 | DataType::Float16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1600 | DataType::QuantisedAsymm8, |
| 1601 | DataType::QuantisedSymm16 |
| 1602 | }; |
| 1603 | |
| 1604 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1605 | "Reference splitter: output type not supported"); |
| 1606 | for (const TensorInfo output : outputs) |
| 1607 | { |
| 1608 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1609 | "Reference splitter: input type not supported"); |
| 1610 | |
| 1611 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1612 | "Reference splitter: input and output types mismatched."); |
| 1613 | } |
| 1614 | |
| 1615 | return supported; |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 1616 | } |
| 1617 | |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1618 | bool RefLayerSupport::IsStackSupported(const std::vector<const TensorInfo*>& inputs, |
| 1619 | const TensorInfo& output, |
| 1620 | const StackDescriptor& descriptor, |
| 1621 | Optional<std::string&> reasonIfUnsupported) const |
| 1622 | { |
| 1623 | ignore_unused(descriptor); |
| 1624 | |
| 1625 | bool supported = true; |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 1626 | std::array<DataType,4> supportedTypes = |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1627 | { |
| 1628 | DataType::Float32, |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 1629 | DataType::Float16, |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1630 | DataType::QuantisedAsymm8, |
| 1631 | DataType::QuantisedSymm16 |
| 1632 | }; |
| 1633 | |
| 1634 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1635 | "Reference stack: output type not supported"); |
| 1636 | for (const TensorInfo* input : inputs) |
| 1637 | { |
| 1638 | BOOST_ASSERT(input != nullptr); |
| 1639 | supported &= CheckSupportRule(TypeAnyOf(*input, supportedTypes), reasonIfUnsupported, |
| 1640 | "Reference stack: input type not supported"); |
| 1641 | |
| 1642 | supported &= CheckSupportRule(TypesAreEqual(*input, output), reasonIfUnsupported, |
| 1643 | "Reference stack: input and output types mismatched."); |
| 1644 | } |
| 1645 | |
| 1646 | return supported; |
| 1647 | } |
| 1648 | |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 1649 | bool RefLayerSupport::IsStridedSliceSupported(const TensorInfo& input, |
| 1650 | const TensorInfo& output, |
| 1651 | const StridedSliceDescriptor& descriptor, |
| 1652 | Optional<std::string&> reasonIfUnsupported) const |
| 1653 | { |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 1654 | ignore_unused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1655 | bool supported = true; |
| 1656 | |
| 1657 | std::array<DataType,3> supportedTypes = |
| 1658 | { |
| 1659 | DataType::Float32, |
| 1660 | DataType::QuantisedAsymm8, |
| 1661 | DataType::QuantisedSymm16 |
| 1662 | }; |
| 1663 | |
| 1664 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1665 | "Reference StridedSlice: input type not supported"); |
| 1666 | |
| 1667 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1668 | "Reference StridedSlice: output type not supported"); |
| 1669 | |
| 1670 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1671 | "Reference StridedSlice: input and output types are mismatched"); |
| 1672 | |
| 1673 | return supported; |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 1674 | } |
| 1675 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1676 | bool RefLayerSupport::IsSubtractionSupported(const TensorInfo& input0, |
| 1677 | const TensorInfo& input1, |
| 1678 | const TensorInfo& output, |
| 1679 | Optional<std::string&> reasonIfUnsupported) const |
| 1680 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1681 | bool supported = true; |
| 1682 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1683 | std::array<DataType,4> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1684 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1685 | DataType::Float16, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1686 | DataType::QuantisedAsymm8, |
| 1687 | DataType::QuantisedSymm16 |
| 1688 | }; |
| 1689 | |
| 1690 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1691 | "Reference subtraction: input 0 is not a supported type."); |
| 1692 | |
| 1693 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1694 | "Reference subtraction: input 1 is not a supported type."); |
| 1695 | |
| 1696 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1697 | "Reference subtraction: output is not a supported type."); |
| 1698 | |
| 1699 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1700 | "Reference subtraction: input 0 and Input 1 types are mismatched"); |
| 1701 | |
| 1702 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1703 | "Reference subtraction: input and output types are mismatched"); |
| 1704 | |
| 1705 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1706 | "Reference subtraction: shapes are not suitable for implicit broadcast."); |
| 1707 | |
| 1708 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1709 | } |
| 1710 | |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 1711 | bool RefLayerSupport::IsPreluSupported(const TensorInfo& input, |
| 1712 | const TensorInfo& alpha, |
| 1713 | const TensorInfo& output, |
| 1714 | Optional<std::string&> reasonIfUnsupported) const |
| 1715 | { |
| 1716 | bool supported = true; |
| 1717 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1718 | std::array<DataType, 4> supportedTypes |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 1719 | { |
| 1720 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1721 | DataType::Float16, |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 1722 | DataType::QuantisedAsymm8, |
| 1723 | DataType::QuantisedSymm16 |
| 1724 | }; |
| 1725 | |
| 1726 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1727 | "PReLU: input is not a supported type."); |
| 1728 | |
| 1729 | supported &= CheckSupportRule(TypeAnyOf(alpha, supportedTypes), reasonIfUnsupported, |
| 1730 | "PReLU: alpha is not a supported type."); |
| 1731 | |
| 1732 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1733 | "PReLU: output is not a supported type."); |
| 1734 | |
| 1735 | supported &= CheckSupportRule(TypesAreEqual(input, alpha, output), reasonIfUnsupported, |
| 1736 | "PReLU: input, alpha and output types are mismatched"); |
| 1737 | |
| 1738 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input, alpha, output), reasonIfUnsupported, |
| 1739 | "PReLU: shapes are not suitable for implicit broadcast"); |
| 1740 | |
| 1741 | return supported; |
| 1742 | } |
| 1743 | |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1744 | bool RefLayerSupport::IsTransposeConvolution2dSupported(const TensorInfo& input, |
| 1745 | const TensorInfo& output, |
| 1746 | const TransposeConvolution2dDescriptor& descriptor, |
| 1747 | const TensorInfo& weights, |
| 1748 | const Optional<TensorInfo>& biases, |
| 1749 | Optional<std::string&> reasonIfUnsupported) const |
| 1750 | { |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1751 | bool supported = true; |
| 1752 | |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1753 | std::array<DataType,4> supportedTypes = |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1754 | { |
| 1755 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1756 | DataType::Float16, |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1757 | DataType::QuantisedAsymm8, |
| 1758 | DataType::QuantisedSymm16 |
| 1759 | }; |
| 1760 | |
| 1761 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1762 | "Reference TransposeConvolution2d: input is not a supported type."); |
| 1763 | |
| 1764 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1765 | "Reference TransposeConvolution2d: output is not a supported type."); |
| 1766 | |
| 1767 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 1768 | "Reference TransposeConvolution2d: weights is not a supported type."); |
| 1769 | |
| 1770 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1771 | "Reference TransposeConvolution2d: input and output types mismatched."); |
| 1772 | |
| 1773 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 1774 | "Reference TransposeConvolution2d: input and weights types mismatched."); |
| 1775 | |
| 1776 | if (biases.has_value()) |
| 1777 | { |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1778 | std::array<DataType,3> biasesSupportedTypes = |
Aron Virginas-Tar | 651aafe | 2019-08-05 11:52:05 +0100 | [diff] [blame] | 1779 | { |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1780 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1781 | DataType::Float16, |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1782 | DataType::Signed32 |
| 1783 | }; |
| 1784 | supported &= CheckSupportRule(TypeAnyOf(biases.value(), biasesSupportedTypes), reasonIfUnsupported, |
| 1785 | "Reference TransposeConvolution2d: biases is not a supported type."); |
| 1786 | } |
| 1787 | |
| 1788 | return supported; |
| 1789 | } |
| 1790 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1791 | } // namespace armnn |