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