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