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