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