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 | |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame^] | 608 | bool RefLayerSupport::IsConvolution3dSupported(const TensorInfo& input, |
| 609 | const TensorInfo& output, |
| 610 | const Convolution3dDescriptor& descriptor, |
| 611 | const TensorInfo& weights, |
| 612 | const Optional<TensorInfo>& biases, |
| 613 | Optional<std::string&> reasonIfUnsupported) const |
| 614 | { |
| 615 | bool supported = true; |
| 616 | |
| 617 | // Define supported types. |
| 618 | std::array<DataType,7> supportedTypes = |
| 619 | { |
| 620 | DataType::BFloat16, |
| 621 | DataType::Float32, |
| 622 | DataType::Float16, |
| 623 | DataType::QAsymmS8, |
| 624 | DataType::QAsymmU8, |
| 625 | DataType::QSymmS8, |
| 626 | DataType::QSymmS16 |
| 627 | }; |
| 628 | |
| 629 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 630 | "Reference Convolution3d: input is not a supported type."); |
| 631 | |
| 632 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 633 | "Reference Convolution3d: output is not a supported type."); |
| 634 | |
| 635 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 636 | "Reference Convolution3d: input and output types mismatched."); |
| 637 | |
| 638 | const DataType inputType = input.GetDataType(); |
| 639 | if (IsQuantized8BitType(inputType)) |
| 640 | { |
| 641 | std::array<DataType, 3> supportedWeightTypes = |
| 642 | { |
| 643 | DataType::QAsymmS8, |
| 644 | DataType::QAsymmU8, |
| 645 | DataType::QSymmS8 |
| 646 | }; |
| 647 | |
| 648 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedWeightTypes), reasonIfUnsupported, |
| 649 | "Reference Convolution3d: weights type not supported for quantized input."); |
| 650 | } |
| 651 | else |
| 652 | { |
| 653 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 654 | "Reference Convolution3d: weights is not a supported type."); |
| 655 | |
| 656 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 657 | "Reference Convolution3d: input and weights types mismatched."); |
| 658 | } |
| 659 | |
| 660 | if (biases.has_value()) |
| 661 | { |
| 662 | std::array<DataType,4> biasesSupportedTypes = |
| 663 | { |
| 664 | DataType::BFloat16, |
| 665 | DataType::Float32, |
| 666 | DataType::Float16, |
| 667 | DataType::Signed32 |
| 668 | }; |
| 669 | |
| 670 | supported &= CheckSupportRule(TypeAnyOf(biases.value(), biasesSupportedTypes), reasonIfUnsupported, |
| 671 | "Reference Convolution3d: biases is not a supported type."); |
| 672 | } |
| 673 | IgnoreUnused(descriptor); |
| 674 | |
| 675 | return supported; |
| 676 | } |
| 677 | |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 678 | bool RefLayerSupport::IsDebugSupported(const TensorInfo& input, |
| 679 | const TensorInfo& output, |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 680 | Optional<std::string&> reasonIfUnsupported) const |
| 681 | { |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 682 | bool supported = true; |
| 683 | |
Narumol Prangnawarat | 403a185 | 2020-03-12 14:24:13 +0000 | [diff] [blame] | 684 | std::array<DataType, 8> supportedTypes = |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 685 | { |
Narumol Prangnawarat | 403a185 | 2020-03-12 14:24:13 +0000 | [diff] [blame] | 686 | DataType::BFloat16, |
Aron Virginas-Tar | db1a283 | 2019-11-12 16:15:11 +0000 | [diff] [blame] | 687 | DataType::Float16, |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 688 | DataType::Float32, |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 689 | DataType::QAsymmS8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 690 | DataType::QAsymmU8, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 691 | DataType::QSymmS8, |
Narumol Prangnawarat | d2d917d | 2020-01-09 10:16:39 +0000 | [diff] [blame] | 692 | DataType::QSymmS16, |
| 693 | DataType::Signed32 |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 694 | }; |
| 695 | |
| 696 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 697 | "Reference for Debug layer: input type not supported"); |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 698 | |
| 699 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 700 | "Reference for Debug layer: output type not supported"); |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 701 | |
| 702 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 703 | "Reference for Debug layer: input and output types are mismatched"); |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 704 | |
| 705 | return supported; |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 706 | } |
| 707 | |
Aron Virginas-Tar | 73f6642 | 2019-09-23 19:11:59 +0100 | [diff] [blame] | 708 | bool RefLayerSupport::IsDepthToSpaceSupported(const TensorInfo& input, |
| 709 | const TensorInfo& output, |
| 710 | const DepthToSpaceDescriptor& descriptor, |
| 711 | Optional<std::string&> reasonIfUnsupported) const |
| 712 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 713 | IgnoreUnused(descriptor); |
Aron Virginas-Tar | 73f6642 | 2019-09-23 19:11:59 +0100 | [diff] [blame] | 714 | bool supported = true; |
| 715 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 716 | std::array<DataType,6> supportedTypes = |
Aron Virginas-Tar | 73f6642 | 2019-09-23 19:11:59 +0100 | [diff] [blame] | 717 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 718 | DataType::BFloat16, |
Aron Virginas-Tar | 73f6642 | 2019-09-23 19:11:59 +0100 | [diff] [blame] | 719 | DataType::Float32, |
| 720 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 721 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 722 | DataType::QAsymmU8, |
| 723 | DataType::QSymmS16 |
Aron Virginas-Tar | 73f6642 | 2019-09-23 19:11:59 +0100 | [diff] [blame] | 724 | }; |
| 725 | |
| 726 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 727 | "Reference DepthToSpace: input type not supported"); |
| 728 | |
| 729 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 730 | "Reference DepthToSpace: output type not supported"); |
| 731 | |
| 732 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 733 | "Reference DepthToSpace: input and output types are mismatched"); |
| 734 | |
| 735 | return supported; |
| 736 | } |
| 737 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 738 | bool RefLayerSupport::IsDepthwiseConvolutionSupported(const TensorInfo& input, |
| 739 | const TensorInfo& output, |
| 740 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 741 | const TensorInfo& weights, |
| 742 | const Optional<TensorInfo>& biases, |
| 743 | Optional<std::string&> reasonIfUnsupported) const |
| 744 | { |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 745 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 746 | bool supported = true; |
| 747 | |
| 748 | // Define supported types. |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 749 | std::array<DataType,7> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 750 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 751 | DataType::BFloat16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 752 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 753 | DataType::Float16, |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 754 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 755 | DataType::QAsymmU8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 756 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 757 | DataType::QSymmS16 |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 758 | }; |
| 759 | |
| 760 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 761 | "Reference DepthwiseConvolution2d: input is not a supported type."); |
| 762 | |
| 763 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 764 | "Reference DepthwiseConvolution2d: output is not a supported type."); |
| 765 | |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 766 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 767 | "Reference DepthwiseConvolution2d: input and output types mismatched."); |
| 768 | |
Teresa Charlin | d8df026 | 2019-11-11 12:28:15 +0000 | [diff] [blame] | 769 | const DataType inputType = input.GetDataType(); |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 770 | if (IsQuantized8BitType(inputType)) |
Teresa Charlin | d8df026 | 2019-11-11 12:28:15 +0000 | [diff] [blame] | 771 | { |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 772 | ARMNN_NO_DEPRECATE_WARN_BEGIN |
| 773 | std::array<DataType, 4> supportedWeightTypes = |
| 774 | { |
| 775 | DataType::QAsymmS8, |
| 776 | DataType::QAsymmU8, |
| 777 | DataType::QSymmS8, |
| 778 | DataType::QuantizedSymm8PerAxis // deprecated |
| 779 | }; |
| 780 | ARMNN_NO_DEPRECATE_WARN_END |
Teresa Charlin | d8df026 | 2019-11-11 12:28:15 +0000 | [diff] [blame] | 781 | |
| 782 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedWeightTypes), reasonIfUnsupported, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 783 | "Reference DepthwiseConvolution2d: weights type not supported for " |
| 784 | "quantized input."); |
Teresa Charlin | d8df026 | 2019-11-11 12:28:15 +0000 | [diff] [blame] | 785 | } |
| 786 | else |
| 787 | { |
| 788 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 789 | "Reference DepthwiseConvolution2d: weights is not a supported type."); |
| 790 | |
| 791 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 792 | "Reference DepthwiseConvolution2d: input and weights types mismatched."); |
| 793 | } |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 794 | |
| 795 | if (biases.has_value()) |
| 796 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 797 | std::array<DataType,4> biasesSupportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 798 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 799 | DataType::BFloat16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 800 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 801 | DataType::Float16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 802 | DataType::Signed32 |
| 803 | }; |
| 804 | supported &= CheckSupportRule(TypeAnyOf(biases.value(), biasesSupportedTypes), reasonIfUnsupported, |
| 805 | "Reference DepthwiseConvolution2d: biases is not a supported type."); |
| 806 | } |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 807 | |
| 808 | return supported; |
| 809 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 810 | } |
| 811 | |
Nattapat Chaimanowong | 8a54ac0 | 2019-03-29 15:25:04 +0000 | [diff] [blame] | 812 | bool RefLayerSupport::IsDequantizeSupported(const TensorInfo& input, |
| 813 | const TensorInfo& output, |
| 814 | Optional<std::string&> reasonIfUnsupported) const |
| 815 | { |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 816 | bool supported = true; |
| 817 | |
Ryan OShea | 9add120 | 2020-02-07 10:06:33 +0000 | [diff] [blame] | 818 | std::array<DataType,4> supportedInputTypes = { |
| 819 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 820 | DataType::QAsymmU8, |
Finn Williams | fd27106 | 2019-12-04 14:27:27 +0000 | [diff] [blame] | 821 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 822 | DataType::QSymmS16 |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 823 | }; |
| 824 | |
| 825 | supported &= CheckSupportRule(TypeAnyOf(input, supportedInputTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 826 | "Reference for Dequantize layer: input type not supported."); |
| 827 | |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 828 | supported &= CheckSupportRule(TypeNotPerAxisQuantized(input), reasonIfUnsupported, |
Teresa Charlin | 1b1950d | 2021-06-02 20:23:21 +0100 | [diff] [blame] | 829 | "Reference for Dequantize layer: per-axis quantized input not supported."); |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 830 | |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 831 | std::array<DataType,3> supportedOutputTypes = { |
| 832 | DataType::BFloat16, |
Jan Eilers | f710793 | 2019-11-01 11:09:36 +0000 | [diff] [blame] | 833 | DataType::Float32, |
| 834 | DataType::Float16 |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 835 | }; |
| 836 | |
| 837 | supported &= CheckSupportRule(TypeAnyOf(output, supportedOutputTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 838 | "Reference for Dequantize layer: output type not supported."); |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 839 | |
| 840 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 841 | "Reference for Dequantize layer: input/output shapes have different num total " |
| 842 | "elements."); |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 843 | |
| 844 | return supported; |
Nattapat Chaimanowong | 8a54ac0 | 2019-03-29 15:25:04 +0000 | [diff] [blame] | 845 | } |
| 846 | |
Derek Lamberti | 6a5e5e8 | 2019-12-05 14:41:20 +0000 | [diff] [blame] | 847 | bool RefLayerSupport::IsDetectionPostProcessSupported(const TensorInfo& boxEncodings, |
| 848 | const TensorInfo& scores, |
| 849 | const TensorInfo& anchors, |
| 850 | const TensorInfo& detectionBoxes, |
| 851 | const TensorInfo& detectionClasses, |
| 852 | const TensorInfo& detectionScores, |
| 853 | const TensorInfo& numDetections, |
| 854 | const DetectionPostProcessDescriptor& descriptor, |
| 855 | Optional<std::string&> reasonIfUnsupported) const |
Narumol Prangnawarat | bc67cef | 2019-01-31 15:31:54 +0000 | [diff] [blame] | 856 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 857 | IgnoreUnused(anchors, detectionBoxes, detectionClasses, detectionScores, numDetections, descriptor); |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 858 | |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 859 | bool supported = true; |
| 860 | |
Sadik Armagan | aa41d5d | 2020-11-16 14:27:52 +0000 | [diff] [blame] | 861 | std::array<DataType,6> supportedInputTypes = |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 862 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 863 | DataType::BFloat16, |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 864 | DataType::Float32, |
Sadik Armagan | aa41d5d | 2020-11-16 14:27:52 +0000 | [diff] [blame] | 865 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 866 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 867 | DataType::QAsymmU8, |
| 868 | DataType::QSymmS16 |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 869 | }; |
| 870 | |
Derek Lamberti | 6a5e5e8 | 2019-12-05 14:41:20 +0000 | [diff] [blame] | 871 | supported &= CheckSupportRule(TypeAnyOf(boxEncodings, supportedInputTypes), reasonIfUnsupported, |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 872 | "Reference DetectionPostProcess: input 0 is not a supported type."); |
| 873 | |
Derek Lamberti | 6a5e5e8 | 2019-12-05 14:41:20 +0000 | [diff] [blame] | 874 | supported &= CheckSupportRule(TypeAnyOf(scores, supportedInputTypes), reasonIfUnsupported, |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 875 | "Reference DetectionPostProcess: input 1 is not a supported type."); |
| 876 | |
| 877 | return supported; |
Narumol Prangnawarat | bc67cef | 2019-01-31 15:31:54 +0000 | [diff] [blame] | 878 | } |
| 879 | |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 880 | bool RefLayerSupport::IsDilatedDepthwiseConvolutionSupported(const TensorInfo& input, |
| 881 | const TensorInfo& output, |
| 882 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 883 | const TensorInfo& weights, |
| 884 | const Optional<TensorInfo>& biases, |
| 885 | Optional<std::string&> reasonIfUnsupported) const |
| 886 | { |
Aron Virginas-Tar | aece4ed | 2019-06-14 17:00:09 +0100 | [diff] [blame] | 887 | return IsDepthwiseConvolutionSupported(input, output, descriptor, weights, biases, reasonIfUnsupported); |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 888 | } |
| 889 | |
Aron Virginas-Tar | aece4ed | 2019-06-14 17:00:09 +0100 | [diff] [blame] | 890 | bool RefLayerSupport::IsDivisionSupported(const TensorInfo& input0, |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 891 | const TensorInfo& input1, |
| 892 | const TensorInfo& output, |
| 893 | Optional<std::string&> reasonIfUnsupported) const |
| 894 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 895 | bool supported = true; |
| 896 | |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 897 | std::array<DataType,7> supportedTypes = { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 898 | DataType::BFloat16, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 899 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 900 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 901 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 902 | DataType::QAsymmU8, |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 903 | DataType::QSymmS16, |
| 904 | DataType::Signed32 |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 905 | }; |
| 906 | |
| 907 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 908 | "Reference division: input 0 is not a supported type."); |
| 909 | |
| 910 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 911 | "Reference division: input 1 is not a supported type."); |
| 912 | |
| 913 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 914 | "Reference division: output is not a supported type."); |
| 915 | |
| 916 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 917 | "Reference division: input 0 and Input 1 types are mismatched"); |
| 918 | |
| 919 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 920 | "Reference division: input and output types are mismatched"); |
| 921 | |
| 922 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 923 | "Reference division: shapes are not suitable for implicit broadcast."); |
| 924 | |
| 925 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 926 | } |
| 927 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 928 | bool RefLayerSupport::IsElementwiseUnarySupported(const TensorInfo& input, |
| 929 | const TensorInfo& output, |
| 930 | const ElementwiseUnaryDescriptor& descriptor, |
| 931 | Optional<std::string&> reasonIfUnsupported) const |
| 932 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 933 | IgnoreUnused(descriptor); |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 934 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 935 | std::array<DataType, 7> supportedTypes = |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 936 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 937 | DataType::BFloat16, |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 938 | DataType::Float32, |
| 939 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 940 | DataType::QAsymmS8, |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 941 | DataType::QAsymmU8, |
Sadik Armagan | ac47210 | 2020-03-24 09:54:36 +0000 | [diff] [blame] | 942 | DataType::QSymmS16, |
| 943 | DataType::Signed32 |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 944 | }; |
| 945 | |
Narumol Prangnawarat | 0c95f4c | 2020-11-18 16:52:07 +0000 | [diff] [blame] | 946 | std::array<DataType, 1> logicalSupportedTypes = |
| 947 | { |
| 948 | DataType::Boolean |
| 949 | }; |
| 950 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 951 | bool supported = true; |
| 952 | |
Narumol Prangnawarat | 0c95f4c | 2020-11-18 16:52:07 +0000 | [diff] [blame] | 953 | if (descriptor.m_Operation == UnaryOperation::LogicalNot) |
| 954 | { |
| 955 | supported &= CheckSupportRule(TypeAnyOf(input, logicalSupportedTypes), reasonIfUnsupported, |
| 956 | "Reference elementwise unary: input type not supported"); |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 957 | |
Narumol Prangnawarat | 0c95f4c | 2020-11-18 16:52:07 +0000 | [diff] [blame] | 958 | supported &= CheckSupportRule(TypeAnyOf(output, logicalSupportedTypes), reasonIfUnsupported, |
| 959 | "Reference elementwise unary: output type not supported"); |
| 960 | } |
| 961 | else |
| 962 | { |
| 963 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 964 | "Reference elementwise unary: input type not supported"); |
| 965 | |
| 966 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 967 | "Reference elementwise unary: output type not supported"); |
| 968 | } |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 969 | |
| 970 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 971 | "Reference elementwise unary: input and output types not matching"); |
| 972 | |
| 973 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 974 | "Reference elementwise unary: input and output shapes" |
| 975 | "have different number of total elements"); |
| 976 | |
| 977 | return supported; |
| 978 | } |
| 979 | |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 980 | bool RefLayerSupport::IsEqualSupported(const TensorInfo& input0, |
| 981 | const TensorInfo& input1, |
| 982 | const TensorInfo& output, |
| 983 | Optional<std::string&> reasonIfUnsupported) const |
| 984 | { |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 985 | return IsComparisonSupported(input0, |
| 986 | input1, |
| 987 | output, |
| 988 | ComparisonDescriptor(ComparisonOperation::Equal), |
| 989 | reasonIfUnsupported); |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 990 | } |
| 991 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 992 | bool RefLayerSupport::IsFakeQuantizationSupported(const TensorInfo& input, |
| 993 | const FakeQuantizationDescriptor& descriptor, |
| 994 | Optional<std::string&> reasonIfUnsupported) const |
| 995 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 996 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 997 | bool supported = true; |
| 998 | |
| 999 | std::array<DataType,1> supportedTypes = |
| 1000 | { |
| 1001 | DataType::Float32 |
| 1002 | }; |
| 1003 | |
| 1004 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1005 | "Reference fake quantization: input type not supported."); |
| 1006 | |
| 1007 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1008 | } |
| 1009 | |
Ryan OShea | f4bfa6a | 2020-06-10 11:33:37 +0100 | [diff] [blame] | 1010 | bool RefLayerSupport::IsFillSupported(const TensorInfo& input, |
| 1011 | const TensorInfo& output, |
| 1012 | const FillDescriptor& descriptor, |
| 1013 | Optional<std::string&> reasonIfUnsupported) const |
| 1014 | { |
| 1015 | IgnoreUnused(descriptor); |
| 1016 | IgnoreUnused(output); |
| 1017 | |
| 1018 | bool supported = true; |
| 1019 | |
Sadik Armagan | a792a05 | 2020-06-23 16:22:23 +0100 | [diff] [blame] | 1020 | std::array<DataType,3> supportedTypes = |
Ryan OShea | f4bfa6a | 2020-06-10 11:33:37 +0100 | [diff] [blame] | 1021 | { |
| 1022 | DataType::Float32, |
Sadik Armagan | a792a05 | 2020-06-23 16:22:23 +0100 | [diff] [blame] | 1023 | DataType::Float16, |
| 1024 | DataType::Signed32 |
Ryan OShea | f4bfa6a | 2020-06-10 11:33:37 +0100 | [diff] [blame] | 1025 | }; |
| 1026 | |
Teresa Charlin | 4b10fef | 2020-07-29 09:36:41 +0100 | [diff] [blame] | 1027 | supported &= CheckSupportRule(TypeIs(input, DataType::Signed32), reasonIfUnsupported, |
Ryan OShea | f4bfa6a | 2020-06-10 11:33:37 +0100 | [diff] [blame] | 1028 | "Reference Fill: input type not supported."); |
| 1029 | |
Teresa Charlin | 4408850 | 2020-07-27 11:27:19 +0100 | [diff] [blame] | 1030 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1031 | "Reference Fill: output type not supported."); |
Ryan OShea | f4bfa6a | 2020-06-10 11:33:37 +0100 | [diff] [blame] | 1032 | return supported; |
| 1033 | } |
| 1034 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1035 | bool RefLayerSupport::IsFloorSupported(const TensorInfo& input, |
| 1036 | const TensorInfo& output, |
| 1037 | Optional<std::string&> reasonIfUnsupported) const |
| 1038 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1039 | IgnoreUnused(output); |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 1040 | bool supported = true; |
| 1041 | |
Francis Murtagh | e8ac133 | 2020-07-30 18:03:40 +0100 | [diff] [blame] | 1042 | std::array<DataType,3> supportedTypes = |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 1043 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1044 | DataType::BFloat16, |
James Conroy | b40d710 | 2019-06-04 12:32:09 +0100 | [diff] [blame] | 1045 | DataType::Float32, |
Francis Murtagh | e8ac133 | 2020-07-30 18:03:40 +0100 | [diff] [blame] | 1046 | DataType::Float16 |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 1047 | }; |
| 1048 | |
| 1049 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1050 | "Reference Floor: input type not supported."); |
| 1051 | |
| 1052 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1053 | "Reference Floor: output type not supported."); |
| 1054 | |
| 1055 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1056 | } |
| 1057 | |
| 1058 | bool RefLayerSupport::IsFullyConnectedSupported(const TensorInfo& input, |
| 1059 | const TensorInfo& output, |
| 1060 | const TensorInfo& weights, |
| 1061 | const TensorInfo& biases, |
| 1062 | const FullyConnectedDescriptor& descriptor, |
| 1063 | Optional<std::string&> reasonIfUnsupported) const |
| 1064 | { |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1065 | bool supported = true; |
| 1066 | |
| 1067 | // Define supported types. |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1068 | std::array<DataType,6> supportedTypes = |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1069 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1070 | DataType::BFloat16, |
| 1071 | DataType::Float32, |
| 1072 | DataType::Float16, |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1073 | DataType::QAsymmS8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1074 | DataType::QAsymmU8, |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1075 | DataType::QSymmS16 |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1076 | }; |
| 1077 | |
| 1078 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1079 | "Reference Fully Connected: input type not supported."); |
| 1080 | |
| 1081 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1082 | "Reference Fully Connected: output type not supported."); |
| 1083 | |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1084 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 1085 | "Reference Fully Connected: weights type not supported."); |
| 1086 | |
Narumol Prangnawarat | 57ef008 | 2020-03-26 09:20:43 +0000 | [diff] [blame] | 1087 | // For FullyConnected, we allow to have BFloat16 input with Float32 output for optimization. |
| 1088 | if (input.GetDataType() == DataType::BFloat16) |
| 1089 | { |
| 1090 | if (output.GetDataType() != DataType::BFloat16 && output.GetDataType() != DataType::Float32) |
| 1091 | { |
| 1092 | reasonIfUnsupported.value() += "Output tensor type must be BFloat16 or Float32 for BFloat16 input.\n"; |
| 1093 | supported = false; |
| 1094 | } |
| 1095 | } |
| 1096 | else |
| 1097 | { |
| 1098 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1099 | "Reference Fully Connected: input and output types mismatched."); |
| 1100 | } |
| 1101 | |
Jan Eilers | 1f45dc3 | 2020-06-15 11:43:03 +0100 | [diff] [blame] | 1102 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 1103 | "Reference Fully Connected: weights is not a supported type."); |
Francis Murtagh | ddb1d06 | 2020-03-10 13:51:45 +0000 | [diff] [blame] | 1104 | |
Jan Eilers | 1f45dc3 | 2020-06-15 11:43:03 +0100 | [diff] [blame] | 1105 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 1106 | "Reference Fully Connected: input and weights types mismatched."); |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1107 | |
| 1108 | if (descriptor.m_BiasEnabled) |
| 1109 | { |
| 1110 | // Defined supported types for bias |
Sadik Armagan | db73c98 | 2020-04-01 17:35:30 +0100 | [diff] [blame] | 1111 | std::array<DataType, 5> |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1112 | supportedBiasTypes = |
| 1113 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1114 | DataType::BFloat16, |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1115 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1116 | DataType::Float16, |
Sadik Armagan | db73c98 | 2020-04-01 17:35:30 +0100 | [diff] [blame] | 1117 | DataType::Signed32, |
| 1118 | DataType::QAsymmS8 |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1119 | }; |
| 1120 | |
| 1121 | supported &= CheckSupportRule(TypeAnyOf(biases, supportedBiasTypes), reasonIfUnsupported, |
| 1122 | "Reference Fully Connected: bias type not supported."); |
| 1123 | |
| 1124 | supported &= CheckSupportRule(BiasAndWeightsTypesMatch(biases, weights), reasonIfUnsupported, |
| 1125 | "Reference Fully Connected: bias and weight types mismatch."); |
| 1126 | |
| 1127 | supported &= CheckSupportRule(BiasAndWeightsTypesCompatible(weights, supportedBiasTypes), reasonIfUnsupported, |
| 1128 | "Reference Fully Connected: bias type inferred from weights is incompatible."); |
| 1129 | |
Narumol Prangnawarat | 366d723 | 2020-04-29 12:58:17 +0100 | [diff] [blame] | 1130 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(biases, 1U), reasonIfUnsupported, |
| 1131 | "Reference Fully Connected: bias must have 1 dimension."); |
| 1132 | |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 1133 | } |
| 1134 | |
| 1135 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1136 | } |
| 1137 | |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 1138 | bool RefLayerSupport::IsGatherSupported(const armnn::TensorInfo& input0, |
| 1139 | const armnn::TensorInfo& input1, |
| 1140 | const armnn::TensorInfo& output, |
Teresa Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 1141 | const GatherDescriptor& descriptor, |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 1142 | armnn::Optional<std::string&> reasonIfUnsupported) const |
| 1143 | { |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 1144 | bool supported = true; |
Teresa Charlin | 3940d8b | 2020-05-29 16:47:23 +0100 | [diff] [blame] | 1145 | std::array<DataType,7> supportedTypes = |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 1146 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1147 | DataType::BFloat16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1148 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1149 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1150 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1151 | DataType::QAsymmU8, |
Teresa Charlin | 3940d8b | 2020-05-29 16:47:23 +0100 | [diff] [blame] | 1152 | DataType::QSymmS16, |
| 1153 | DataType::Signed32 |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 1154 | }; |
| 1155 | |
Teresa Charlin | 5266473 | 2020-06-29 16:27:03 +0100 | [diff] [blame] | 1156 | if (descriptor.m_Axis != 0) |
| 1157 | { |
| 1158 | reasonIfUnsupported.value() += std::string("Reference Gather: axis not supported\n"); |
| 1159 | supported &= false; |
| 1160 | } |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 1161 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1162 | "Reference Gather: input type not supported"); |
| 1163 | |
| 1164 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1165 | "Reference Gather: output type not supported"); |
| 1166 | |
| 1167 | supported &= CheckSupportRule(TypeIs(input1, DataType::Signed32), reasonIfUnsupported, |
| 1168 | "Reference Gather: indices (input1) type not supported"); |
| 1169 | |
| 1170 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1171 | "Reference Gather: input and output types not matching"); |
| 1172 | |
| 1173 | return supported; |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 1174 | } |
| 1175 | |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 1176 | bool RefLayerSupport::IsGreaterSupported(const TensorInfo& input0, |
| 1177 | const TensorInfo& input1, |
| 1178 | const TensorInfo& output, |
| 1179 | Optional<std::string&> reasonIfUnsupported) const |
| 1180 | { |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 1181 | return IsComparisonSupported(input0, |
| 1182 | input1, |
| 1183 | output, |
| 1184 | ComparisonDescriptor(ComparisonOperation::Greater), |
| 1185 | reasonIfUnsupported); |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 1186 | } |
| 1187 | |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 1188 | bool RefLayerSupport::IsInputSupported(const TensorInfo& /*input*/, |
| 1189 | Optional<std::string&> /*reasonIfUnsupported*/) const |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1190 | { |
Narumol Prangnawarat | b6441e4 | 2019-06-04 11:22:00 +0100 | [diff] [blame] | 1191 | return true; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1192 | } |
| 1193 | |
Kevin May | 09ca49c | 2019-10-09 12:37:34 +0100 | [diff] [blame] | 1194 | bool RefLayerSupport::IsInstanceNormalizationSupported(const TensorInfo& input, |
| 1195 | const TensorInfo& output, |
| 1196 | const InstanceNormalizationDescriptor& descriptor, |
| 1197 | Optional<std::string&> reasonIfUnsupported) const |
| 1198 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1199 | IgnoreUnused(descriptor); |
Kevin May | 09ca49c | 2019-10-09 12:37:34 +0100 | [diff] [blame] | 1200 | // Define supported types |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1201 | std::array<DataType, 3> supportedTypes = |
Kevin May | 09ca49c | 2019-10-09 12:37:34 +0100 | [diff] [blame] | 1202 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1203 | DataType::BFloat16, |
Kevin May | 09ca49c | 2019-10-09 12:37:34 +0100 | [diff] [blame] | 1204 | DataType::Float32, |
| 1205 | DataType::Float16 |
| 1206 | }; |
| 1207 | |
| 1208 | bool supported = true; |
| 1209 | |
| 1210 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1211 | "Reference Instance Normalization: input type not supported."); |
| 1212 | |
| 1213 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1214 | "Reference Instance Normalization: output type not supported."); |
| 1215 | |
| 1216 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1217 | "Reference Instance Normalization: input and output types mismatched."); |
| 1218 | |
| 1219 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1220 | "Reference Instance Normalization: input and output shapes have different " |
| 1221 | "num total elements."); |
| 1222 | |
| 1223 | return supported; |
| 1224 | } |
| 1225 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1226 | bool RefLayerSupport::IsL2NormalizationSupported(const TensorInfo& input, |
| 1227 | const TensorInfo& output, |
| 1228 | const L2NormalizationDescriptor& descriptor, |
| 1229 | Optional<std::string&> reasonIfUnsupported) const |
| 1230 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1231 | IgnoreUnused(descriptor); |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 1232 | // Define supported types |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1233 | std::array<DataType, 6> supportedTypes = |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 1234 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1235 | DataType::BFloat16, |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 1236 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1237 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1238 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1239 | DataType::QAsymmU8, |
| 1240 | DataType::QSymmS16 |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 1241 | }; |
| 1242 | |
| 1243 | bool supported = true; |
| 1244 | |
| 1245 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1246 | "Reference L2normalization: input type not supported."); |
| 1247 | |
| 1248 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1249 | "Reference L2normalization: output type not supported."); |
| 1250 | |
| 1251 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1252 | "Reference L2normalization: input and output types mismatched."); |
| 1253 | |
| 1254 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1255 | "Reference L2normalization: input and output shapes have different " |
| 1256 | "num total elements."); |
| 1257 | |
| 1258 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1259 | } |
| 1260 | |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 1261 | bool RefLayerSupport::IsLogicalBinarySupported(const TensorInfo& input0, |
| 1262 | const TensorInfo& input1, |
| 1263 | const TensorInfo& output, |
| 1264 | const LogicalBinaryDescriptor& descriptor, |
| 1265 | Optional<std::string&> reasonIfUnsupported) const |
| 1266 | { |
| 1267 | IgnoreUnused(descriptor); |
| 1268 | |
| 1269 | std::array<DataType, 1> supportedTypes = |
| 1270 | { |
| 1271 | DataType::Boolean |
| 1272 | }; |
| 1273 | |
| 1274 | bool supported = true; |
| 1275 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1276 | "Reference LogicalBinary: input 0 type not supported"); |
| 1277 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1278 | "Reference LogicalBinary: input 1 type not supported"); |
| 1279 | |
| 1280 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1281 | "Reference LogicalBinary: input and output types do not match"); |
| 1282 | |
| 1283 | return supported; |
| 1284 | } |
| 1285 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1286 | bool RefLayerSupport::IsLogSoftmaxSupported(const TensorInfo& input, |
| 1287 | const TensorInfo& output, |
| 1288 | const LogSoftmaxDescriptor& descriptor, |
| 1289 | Optional<std::string&> reasonIfUnsupported) const |
| 1290 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1291 | IgnoreUnused(descriptor); |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1292 | |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1293 | std::array<DataType, 3> supportedTypes = |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1294 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1295 | DataType::BFloat16, |
| 1296 | DataType::Float32, |
| 1297 | DataType::Float16 |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1298 | }; |
| 1299 | |
| 1300 | bool supported = true; |
| 1301 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1302 | "Reference LogSoftmax: input type not supported"); |
| 1303 | |
| 1304 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1305 | "Reference LogSoftmax: output type not supported"); |
| 1306 | |
| 1307 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1308 | "Reference LogSoftmax: input and output types do not match"); |
| 1309 | |
| 1310 | return supported; |
| 1311 | } |
| 1312 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1313 | bool RefLayerSupport::IsLstmSupported(const TensorInfo& input, |
| 1314 | const TensorInfo& outputStateIn, |
| 1315 | const TensorInfo& cellStateIn, |
| 1316 | const TensorInfo& scratchBuffer, |
| 1317 | const TensorInfo& outputStateOut, |
| 1318 | const TensorInfo& cellStateOut, |
| 1319 | const TensorInfo& output, |
| 1320 | const LstmDescriptor& descriptor, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1321 | const LstmInputParamsInfo& paramsInfo, |
| 1322 | Optional<std::string&> reasonIfUnsupported) const |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1323 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1324 | IgnoreUnused(descriptor); |
| 1325 | IgnoreUnused(paramsInfo); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1326 | |
| 1327 | bool supported = true; |
| 1328 | |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1329 | std::array<DataType,3> supportedTypes = { |
| 1330 | DataType::BFloat16, |
Conor Kennedy | b9971c9 | 2019-05-07 07:14:23 +0100 | [diff] [blame] | 1331 | DataType::Float32, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1332 | DataType::QSymmS16 |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1333 | }; |
| 1334 | |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1335 | // check inputs and outputs |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1336 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1337 | "Reference Lstm: input is not a supported type."); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1338 | supported &= CheckSupportRule(TypesAreEqual(input, outputStateIn), reasonIfUnsupported, |
| 1339 | "Reference Lstm: input and outputStateIn types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1340 | supported &= CheckSupportRule(TypesAreEqual(input, cellStateIn), reasonIfUnsupported, |
| 1341 | "Reference Lstm: input and cellStateIn types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1342 | supported &= CheckSupportRule(TypesAreEqual(input, scratchBuffer), reasonIfUnsupported, |
| 1343 | "Reference Lstm: input and scratchBuffer types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1344 | supported &= CheckSupportRule(TypesAreEqual(input, outputStateOut), reasonIfUnsupported, |
| 1345 | "Reference Lstm: input and outputStateOut types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1346 | supported &= CheckSupportRule(TypesAreEqual(input, cellStateOut), reasonIfUnsupported, |
| 1347 | "Reference Lstm: input and cellStateOut types are mismatched"); |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 1348 | |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1349 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1350 | "Reference Lstm: input and output types are mismatched"); |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1351 | // check layer parameters |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1352 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToForgetWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1353 | "Reference Lstm: input and InputToForgetWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1354 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToCellWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1355 | "Reference Lstm: input and InputToCellWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1356 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToOutputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1357 | "Reference Lstm: input and InputToOutputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1358 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToForgetWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1359 | "Reference Lstm: input and RecurrentToForgetWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1360 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToCellWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1361 | "Reference Lstm: input and RecurrentToCellWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1362 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToOutputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1363 | "Reference Lstm: input and RecurrentToOutputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1364 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetForgetGateBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1365 | "Reference Lstm: input and ForgetGateBias types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1366 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1367 | "Reference Lstm: input and CellBias types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1368 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetOutputGateBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1369 | "Reference Lstm: input and OutputGateBias types are mismatched"); |
| 1370 | if (!descriptor.m_CifgEnabled) |
| 1371 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1372 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToInputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1373 | "Reference Lstm: input and InputToInputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1374 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToInputWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1375 | reasonIfUnsupported, |
| 1376 | "Reference Lstm: input and RecurrentToInputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1377 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputGateBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1378 | "Reference Lstm: input and InputGateBias types are mismatched"); |
| 1379 | if (descriptor.m_PeepholeEnabled) |
| 1380 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1381 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellToInputWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1382 | reasonIfUnsupported, |
| 1383 | "Reference Lstm: input and CellToInputWeights types are mismatched"); |
| 1384 | } |
| 1385 | } |
| 1386 | if (descriptor.m_PeepholeEnabled) |
| 1387 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1388 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellToForgetWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1389 | "Reference Lstm: input and CellToForgetWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1390 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellToOutputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1391 | "Reference Lstm: input and CellToOutputWeights types are mismatched"); |
| 1392 | } |
| 1393 | if (descriptor.m_ProjectionEnabled) |
| 1394 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1395 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetProjectionWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1396 | "Reference Lstm: input and mProjectionWeights types are mismatched"); |
| 1397 | if (paramsInfo.m_ProjectionBias != nullptr) |
| 1398 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1399 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetProjectionBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1400 | "Reference Lstm: input and ProjectionBias types are mismatched"); |
| 1401 | } |
| 1402 | } |
| 1403 | if (descriptor.m_LayerNormEnabled) |
| 1404 | { |
| 1405 | if (!descriptor.m_CifgEnabled) |
| 1406 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1407 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1408 | reasonIfUnsupported, |
| 1409 | "Reference Lstm: input and InputLayerNormWeights types are mismatched"); |
| 1410 | } |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1411 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetForgetLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1412 | reasonIfUnsupported, |
| 1413 | "Reference Lstm: input and ForgetLayerNormWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1414 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1415 | reasonIfUnsupported, |
| 1416 | "Reference Lstm: input and CellLayerNormWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1417 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetOutputLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1418 | reasonIfUnsupported, |
| 1419 | "Reference Lstm: input and OutputLayerNormWeights types are mismatched"); |
| 1420 | } |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1421 | |
| 1422 | return supported; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1423 | } |
| 1424 | |
saoste01 | 2df12b3 | 2018-11-28 16:57:20 +0000 | [diff] [blame] | 1425 | bool RefLayerSupport::IsMaximumSupported(const TensorInfo& input0, |
| 1426 | const TensorInfo& input1, |
| 1427 | const TensorInfo& output, |
| 1428 | Optional<std::string&> reasonIfUnsupported) const |
| 1429 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1430 | bool supported = true; |
| 1431 | |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 1432 | std::array<DataType,7> supportedTypes = { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1433 | DataType::BFloat16, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1434 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1435 | DataType::Float16, |
Keith Davis | 67e6c54 | 2020-02-19 10:08:33 +0000 | [diff] [blame] | 1436 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1437 | DataType::QAsymmU8, |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 1438 | DataType::QSymmS16, |
| 1439 | DataType::Signed32 |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1440 | }; |
| 1441 | |
| 1442 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1443 | "Reference maximum: input 0 is not a supported type."); |
| 1444 | |
| 1445 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1446 | "Reference maximum: input 1 is not a supported type."); |
| 1447 | |
| 1448 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1449 | "Reference maximum: output is not a supported type."); |
| 1450 | |
| 1451 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1452 | "Reference maximum: input 0 and Input 1 types are mismatched"); |
| 1453 | |
| 1454 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1455 | "Reference maximum: input and output types are mismatched"); |
| 1456 | |
| 1457 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1458 | "Reference maximum: shapes are not suitable for implicit broadcast."); |
| 1459 | |
| 1460 | return supported; |
saoste01 | 2df12b3 | 2018-11-28 16:57:20 +0000 | [diff] [blame] | 1461 | } |
| 1462 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1463 | bool RefLayerSupport::IsMeanSupported(const TensorInfo& input, |
| 1464 | const TensorInfo& output, |
| 1465 | const MeanDescriptor& descriptor, |
| 1466 | Optional<std::string&> reasonIfUnsupported) const |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 1467 | { |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1468 | bool supported = true; |
| 1469 | std::string meanLayerStr = "Mean"; |
| 1470 | std::string outputTensorStr = "output"; |
| 1471 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1472 | std::array<DataType,6> supportedTypes = |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1473 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1474 | DataType::BFloat16, |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1475 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1476 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1477 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1478 | DataType::QAsymmU8, |
| 1479 | DataType::QSymmS16 |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1480 | }; |
| 1481 | |
| 1482 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1483 | "Reference Mean: input type not supported."); |
| 1484 | |
| 1485 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1486 | "Reference Mean: input and output types are mismatched"); |
| 1487 | |
| 1488 | if (descriptor.m_KeepDims) |
| 1489 | { |
| 1490 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, input.GetNumDimensions()), |
| 1491 | reasonIfUnsupported, |
| 1492 | CreateIncorrectDimensionsErrorMsg(input.GetNumDimensions(), |
| 1493 | output.GetNumDimensions(), |
| 1494 | meanLayerStr, outputTensorStr).data()); |
| 1495 | } |
| 1496 | else if (descriptor.m_Axis.empty()) |
| 1497 | { |
| 1498 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, 1), |
| 1499 | reasonIfUnsupported, |
| 1500 | CreateIncorrectDimensionsErrorMsg(1, output.GetNumDimensions(), |
| 1501 | meanLayerStr, outputTensorStr).data()); |
| 1502 | } |
| 1503 | else |
| 1504 | { |
Matthew Sloyan | 171214c | 2020-09-09 09:07:37 +0100 | [diff] [blame] | 1505 | 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] | 1506 | |
| 1507 | if (outputDim > 0) |
| 1508 | { |
| 1509 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, outputDim), |
| 1510 | reasonIfUnsupported, |
| 1511 | CreateIncorrectDimensionsErrorMsg(outputDim, output.GetNumDimensions(), |
| 1512 | meanLayerStr, outputTensorStr).data()); |
| 1513 | } |
| 1514 | else |
| 1515 | { |
| 1516 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, 1), |
| 1517 | reasonIfUnsupported, |
| 1518 | CreateIncorrectDimensionsErrorMsg(1, output.GetNumDimensions(), |
| 1519 | meanLayerStr, outputTensorStr).data()); |
| 1520 | } |
| 1521 | } |
| 1522 | |
| 1523 | return supported; |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 1524 | } |
| 1525 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1526 | bool RefLayerSupport::IsMergerSupported(const std::vector<const TensorInfo*> inputs, |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 1527 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1528 | const MergerDescriptor& descriptor, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1529 | Optional<std::string&> reasonIfUnsupported) const |
| 1530 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1531 | return IsConcatSupported(inputs, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1532 | } |
| 1533 | |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1534 | bool RefLayerSupport::IsMemCopySupported(const TensorInfo &input, |
| 1535 | const TensorInfo &output, |
| 1536 | Optional<std::string &> reasonIfUnsupported) const |
| 1537 | { |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1538 | bool supported = true; |
| 1539 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1540 | std::array<DataType,7> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1541 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1542 | DataType::BFloat16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1543 | DataType::Float32, |
| 1544 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1545 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1546 | DataType::QAsymmU8, |
| 1547 | DataType::QSymmS16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1548 | DataType::Boolean |
| 1549 | }; |
| 1550 | |
| 1551 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1552 | "Reference MemCopy: input type not supported"); |
| 1553 | |
| 1554 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1555 | "Reference MemCopy: output type not supported"); |
| 1556 | |
| 1557 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1558 | "Reference MemCopy: input and output types are mismatched"); |
| 1559 | |
| 1560 | return supported; |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1561 | } |
| 1562 | |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 1563 | bool RefLayerSupport::IsMinimumSupported(const TensorInfo& input0, |
| 1564 | const TensorInfo& input1, |
| 1565 | const TensorInfo& output, |
| 1566 | Optional<std::string&> reasonIfUnsupported) const |
| 1567 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1568 | bool supported = true; |
| 1569 | |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 1570 | std::array<DataType,7> supportedTypes = { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1571 | DataType::BFloat16, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1572 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1573 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1574 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1575 | DataType::QAsymmU8, |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 1576 | DataType::QSymmS16, |
| 1577 | DataType::Signed32 |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1578 | }; |
| 1579 | |
| 1580 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1581 | "Reference minimum: input 0 is not a supported type."); |
| 1582 | |
| 1583 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1584 | "Reference minimum: input 1 is not a supported type."); |
| 1585 | |
| 1586 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1587 | "Reference minimum: output is not a supported type."); |
| 1588 | |
| 1589 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1590 | "Reference minimum: input 0 and Input 1 types are mismatched"); |
| 1591 | |
| 1592 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1593 | "Reference minimum: input and output types are mismatched"); |
| 1594 | |
| 1595 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1596 | "Reference minimum: shapes are not suitable for implicit broadcast."); |
| 1597 | |
| 1598 | return supported; |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 1599 | } |
| 1600 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1601 | bool RefLayerSupport::IsMultiplicationSupported(const TensorInfo& input0, |
| 1602 | const TensorInfo& input1, |
| 1603 | const TensorInfo& output, |
| 1604 | Optional<std::string&> reasonIfUnsupported) const |
| 1605 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1606 | bool supported = true; |
| 1607 | |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 1608 | std::array<DataType,7> supportedTypes = { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1609 | DataType::BFloat16, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1610 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1611 | DataType::Float16, |
Keith Davis | 67e6c54 | 2020-02-19 10:08:33 +0000 | [diff] [blame] | 1612 | DataType::QAsymmS8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1613 | DataType::QAsymmU8, |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 1614 | DataType::QSymmS16, |
| 1615 | DataType::Signed32 |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1616 | }; |
| 1617 | |
| 1618 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1619 | "Reference multiplication: input 0 is not a supported type."); |
| 1620 | |
| 1621 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1622 | "Reference multiplication: input 1 is not a supported type."); |
| 1623 | |
| 1624 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1625 | "Reference multiplication: output is not a supported type."); |
| 1626 | |
| 1627 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1628 | "Reference multiplication: input 0 and Input 1 types are mismatched"); |
| 1629 | |
| 1630 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1631 | "Reference multiplication: input and output types are mismatched"); |
| 1632 | |
| 1633 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1634 | "Reference multiplication: shapes are not suitable for implicit broadcast."); |
| 1635 | |
| 1636 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1637 | } |
| 1638 | |
| 1639 | bool RefLayerSupport::IsNormalizationSupported(const TensorInfo& input, |
| 1640 | const TensorInfo& output, |
| 1641 | const NormalizationDescriptor& descriptor, |
| 1642 | Optional<std::string&> reasonIfUnsupported) const |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 1643 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1644 | IgnoreUnused(descriptor); |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1645 | |
| 1646 | // Define supported types |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1647 | std::array<DataType, 6> supportedTypes = |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1648 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1649 | DataType::BFloat16, |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1650 | DataType::Float16, |
| 1651 | DataType::Float32, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1652 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1653 | DataType::QAsymmU8, |
| 1654 | DataType::QSymmS16 |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1655 | }; |
| 1656 | |
| 1657 | bool supported = true; |
| 1658 | |
| 1659 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1660 | "Reference normalization: input type not supported."); |
| 1661 | |
| 1662 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1663 | "Reference normalization: output type not supported."); |
| 1664 | |
| 1665 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1666 | "Reference normalization: input and output shapes have different " |
| 1667 | "num total elements."); |
| 1668 | |
| 1669 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1670 | } |
| 1671 | |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 1672 | bool RefLayerSupport::IsOutputSupported(const TensorInfo& /*output*/, |
| 1673 | Optional<std::string&> /*reasonIfUnsupported*/) const |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1674 | { |
Narumol Prangnawarat | b6441e4 | 2019-06-04 11:22:00 +0100 | [diff] [blame] | 1675 | return true; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1676 | } |
| 1677 | |
| 1678 | bool RefLayerSupport::IsPadSupported(const TensorInfo& input, |
| 1679 | const TensorInfo& output, |
| 1680 | const PadDescriptor& descriptor, |
| 1681 | Optional<std::string&> reasonIfUnsupported) const |
| 1682 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1683 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 1684 | bool supported = true; |
| 1685 | |
| 1686 | // Define supported output and inputs types. |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1687 | std::array<DataType,6> supportedTypes = |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 1688 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1689 | DataType::BFloat16, |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 1690 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1691 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1692 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1693 | DataType::QAsymmU8, |
| 1694 | DataType::QSymmS16 |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 1695 | }; |
| 1696 | |
| 1697 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1698 | "Reference pad: input is not a supported type."); |
| 1699 | |
| 1700 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1701 | "Reference pad: output is not a supported type."); |
| 1702 | |
| 1703 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1704 | "Reference pad: input and output types are mismatched."); |
| 1705 | |
| 1706 | return supported; |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 1707 | } |
| 1708 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1709 | bool RefLayerSupport::IsPermuteSupported(const TensorInfo& input, |
| 1710 | const TensorInfo& output, |
| 1711 | const PermuteDescriptor& descriptor, |
| 1712 | Optional<std::string&> reasonIfUnsupported) const |
| 1713 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1714 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 1715 | bool supported = true; |
| 1716 | |
| 1717 | // Define supported output and inputs types. |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1718 | std::array<DataType, 6> supportedTypes = |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 1719 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1720 | DataType::BFloat16, |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 1721 | DataType::Float32, |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 1722 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1723 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1724 | DataType::QAsymmU8, |
| 1725 | DataType::QSymmS16 |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 1726 | }; |
| 1727 | |
| 1728 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1729 | "Reference permute: input is not a supported type."); |
| 1730 | |
| 1731 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1732 | "Reference permute: output is not a supported type."); |
| 1733 | |
| 1734 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1735 | "Reference permute: input and output types are mismatched."); |
| 1736 | |
| 1737 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1738 | } |
| 1739 | |
| 1740 | bool RefLayerSupport::IsPooling2dSupported(const TensorInfo& input, |
| 1741 | const TensorInfo& output, |
| 1742 | const Pooling2dDescriptor& descriptor, |
| 1743 | Optional<std::string&> reasonIfUnsupported) const |
| 1744 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1745 | IgnoreUnused(descriptor); |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1746 | bool supported = true; |
| 1747 | |
| 1748 | // Define supported output and inputs types. |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1749 | std::array<DataType,6> supportedTypes = |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1750 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1751 | DataType::BFloat16, |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1752 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1753 | DataType::Float16, |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 1754 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1755 | DataType::QAsymmU8, |
| 1756 | DataType::QSymmS16 |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1757 | }; |
| 1758 | |
| 1759 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1760 | "Reference poolind2d: input is not a supported type."); |
| 1761 | |
| 1762 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1763 | "Reference poolind2d: output is not a supported type."); |
| 1764 | |
| 1765 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1766 | "Reference poolind2d: input and output types are mismatched."); |
| 1767 | |
| 1768 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1769 | } |
| 1770 | |
James Conroy | 4f1f899 | 2020-04-29 20:01:10 +0100 | [diff] [blame] | 1771 | bool RefLayerSupport::IsQLstmSupported(const TensorInfo& input, |
| 1772 | const TensorInfo& previousOutputIn, |
| 1773 | const TensorInfo& previousCellStateIn, |
| 1774 | const TensorInfo& outputStateOut, |
| 1775 | const TensorInfo& cellStateOut, |
| 1776 | const TensorInfo& output, |
| 1777 | const QLstmDescriptor& descriptor, |
| 1778 | const LstmInputParamsInfo& paramsInfo, |
| 1779 | Optional<std::string&> reasonIfUnsupported) const |
| 1780 | { |
| 1781 | IgnoreUnused(input); |
| 1782 | IgnoreUnused(previousOutputIn); |
| 1783 | IgnoreUnused(previousCellStateIn); |
| 1784 | IgnoreUnused(outputStateOut); |
| 1785 | IgnoreUnused(cellStateOut); |
| 1786 | IgnoreUnused(output); |
| 1787 | IgnoreUnused(descriptor); |
| 1788 | IgnoreUnused(paramsInfo); |
| 1789 | |
| 1790 | IgnoreUnused(reasonIfUnsupported); |
| 1791 | |
| 1792 | return true; |
| 1793 | } |
| 1794 | |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1795 | bool RefLayerSupport::IsQuantizeSupported(const TensorInfo& input, |
| 1796 | const TensorInfo& output, |
| 1797 | Optional<std::string&> reasonIfUnsupported) const |
| 1798 | { |
| 1799 | bool supported = true; |
| 1800 | |
Finn Williams | fd27106 | 2019-12-04 14:27:27 +0000 | [diff] [blame] | 1801 | // Define supported input types. |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1802 | std::array<DataType,7> supportedInputTypes = { |
| 1803 | DataType::BFloat16, |
Keith Davis | 5e51cd8 | 2020-01-29 16:52:59 +0000 | [diff] [blame] | 1804 | DataType::Float32, |
Keith Davis | 3d8bc97 | 2020-02-04 09:31:47 +0000 | [diff] [blame] | 1805 | DataType::Float16, |
Ryan OShea | 9add120 | 2020-02-07 10:06:33 +0000 | [diff] [blame] | 1806 | DataType::QAsymmS8, |
Keith Davis | 5e51cd8 | 2020-01-29 16:52:59 +0000 | [diff] [blame] | 1807 | DataType::QAsymmU8, |
| 1808 | DataType::QSymmS8, |
| 1809 | DataType::QSymmS16 |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1810 | }; |
| 1811 | |
| 1812 | supported &= CheckSupportRule(TypeAnyOf(input, supportedInputTypes), reasonIfUnsupported, |
| 1813 | "Reference quantize: input type not supported."); |
| 1814 | |
| 1815 | // Define supported output types. |
Ryan OShea | 9add120 | 2020-02-07 10:06:33 +0000 | [diff] [blame] | 1816 | std::array<DataType,4> supportedOutputTypes = { |
Ryan OShea | 9add120 | 2020-02-07 10:06:33 +0000 | [diff] [blame] | 1817 | DataType::QAsymmS8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1818 | DataType::QAsymmU8, |
Finn Williams | fd27106 | 2019-12-04 14:27:27 +0000 | [diff] [blame] | 1819 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1820 | DataType::QSymmS16 |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1821 | }; |
| 1822 | supported &= CheckSupportRule(TypeAnyOf(output, supportedOutputTypes), reasonIfUnsupported, |
| 1823 | "Reference quantize: output type not supported."); |
| 1824 | |
| 1825 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1826 | "Reference quantize: input and output shapes have different num total elements."); |
| 1827 | |
| 1828 | return supported; |
| 1829 | } |
| 1830 | |
Finn Williams | 2605b23 | 2020-06-10 15:53:46 +0100 | [diff] [blame] | 1831 | bool RefLayerSupport::IsRankSupported(const TensorInfo& input, |
| 1832 | const TensorInfo& output, |
| 1833 | Optional<std::string&> reasonIfUnsupported) const |
| 1834 | { |
| 1835 | IgnoreUnused(input); |
| 1836 | // Define supported output types. |
| 1837 | std::array<DataType,1> supportedOutputTypes = |
| 1838 | { |
| 1839 | DataType::Signed32, |
| 1840 | }; |
| 1841 | |
| 1842 | return CheckSupportRule(TypeAnyOf(output, supportedOutputTypes), reasonIfUnsupported, |
| 1843 | "Reference rank: input type not supported."); |
| 1844 | } |
| 1845 | |
Sadik Armagan | 0c3ea5b | 2021-02-03 09:29:30 +0000 | [diff] [blame] | 1846 | bool RefLayerSupport::IsReduceSupported(const TensorInfo& input, |
| 1847 | const TensorInfo& output, |
| 1848 | const ReduceDescriptor& descriptor, |
| 1849 | Optional<std::string&> reasonIfUnsupported) const |
| 1850 | { |
| 1851 | IgnoreUnused(descriptor); |
| 1852 | bool supported = true; |
| 1853 | std::array<DataType,7> supportedTypes = |
| 1854 | { |
| 1855 | DataType::BFloat16, |
| 1856 | DataType::Float32, |
| 1857 | DataType::Float16, |
| 1858 | DataType::QAsymmS8, |
| 1859 | DataType::QAsymmU8, |
| 1860 | DataType::QSymmS16, |
| 1861 | DataType::Signed32 |
| 1862 | }; |
| 1863 | |
| 1864 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1865 | "Reference Reduce: input type not supported"); |
| 1866 | |
| 1867 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1868 | "Reference Reduce: output type not supported"); |
| 1869 | |
| 1870 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1871 | "Reference Reduce: input and output types not matching"); |
| 1872 | |
| 1873 | return supported; |
| 1874 | } |
| 1875 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1876 | bool RefLayerSupport::IsReshapeSupported(const TensorInfo& input, |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 1877 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1878 | const ReshapeDescriptor& descriptor, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1879 | Optional<std::string&> reasonIfUnsupported) const |
| 1880 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1881 | IgnoreUnused(output); |
| 1882 | IgnoreUnused(descriptor); |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1883 | // Define supported output types. |
Narumol Prangnawarat | 0c95f4c | 2020-11-18 16:52:07 +0000 | [diff] [blame] | 1884 | std::array<DataType,8> supportedOutputTypes = |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1885 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1886 | DataType::BFloat16, |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1887 | DataType::Float32, |
| 1888 | DataType::Float16, |
Narumol Prangnawarat | 0718ee9 | 2019-09-13 16:53:38 +0100 | [diff] [blame] | 1889 | DataType::Signed32, |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 1890 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1891 | DataType::QAsymmU8, |
Narumol Prangnawarat | 0c95f4c | 2020-11-18 16:52:07 +0000 | [diff] [blame] | 1892 | DataType::QSymmS16, |
| 1893 | DataType::Boolean |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1894 | }; |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 1895 | |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1896 | return CheckSupportRule(TypeAnyOf(input, supportedOutputTypes), reasonIfUnsupported, |
| 1897 | "Reference reshape: input type not supported."); |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1898 | } |
| 1899 | |
| 1900 | bool RefLayerSupport::IsResizeBilinearSupported(const TensorInfo& input, |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame] | 1901 | const TensorInfo& output, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1902 | Optional<std::string&> reasonIfUnsupported) const |
| 1903 | { |
Ellen Norris-Thompson | 3cb85f3 | 2019-06-17 11:32:49 +0100 | [diff] [blame] | 1904 | bool supported = true; |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1905 | std::array<DataType,6> supportedTypes = |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1906 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1907 | DataType::BFloat16, |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1908 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1909 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1910 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1911 | DataType::QAsymmU8, |
| 1912 | DataType::QSymmS16 |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1913 | }; |
Ellen Norris-Thompson | 3cb85f3 | 2019-06-17 11:32:49 +0100 | [diff] [blame] | 1914 | |
| 1915 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1916 | "Reference ResizeBilinear: input type not supported"); |
| 1917 | |
| 1918 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1919 | "Reference ResizeBilinear: output type not supported"); |
| 1920 | |
| 1921 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1922 | "Reference ResizeBilinear: input and output types not matching"); |
| 1923 | |
| 1924 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1925 | } |
| 1926 | |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1927 | bool RefLayerSupport::IsResizeSupported(const TensorInfo& input, |
| 1928 | const TensorInfo& output, |
| 1929 | const ResizeDescriptor& descriptor, |
| 1930 | Optional<std::string&> reasonIfUnsupported) const |
| 1931 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1932 | IgnoreUnused(descriptor); |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1933 | bool supported = true; |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1934 | std::array<DataType,6> supportedTypes = |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1935 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1936 | DataType::BFloat16, |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1937 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1938 | DataType::Float16, |
Keith Davis | 67e6c54 | 2020-02-19 10:08:33 +0000 | [diff] [blame] | 1939 | DataType::QAsymmS8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1940 | DataType::QAsymmU8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1941 | DataType::QSymmS16 |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1942 | }; |
| 1943 | |
| 1944 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1945 | "Reference Resize: input type not supported"); |
| 1946 | |
| 1947 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1948 | "Reference Resize: output type not supported"); |
| 1949 | |
| 1950 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1951 | "Reference Resize: input and output types not matching"); |
| 1952 | |
| 1953 | return supported; |
| 1954 | } |
| 1955 | |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 1956 | bool RefLayerSupport::IsRsqrtSupported(const TensorInfo& input, |
| 1957 | const TensorInfo& output, |
| 1958 | Optional<std::string&> reasonIfUnsupported) const |
| 1959 | { |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 1960 | return IsElementwiseUnarySupported(input, |
| 1961 | output, |
| 1962 | ElementwiseUnaryDescriptor(UnaryOperation::Rsqrt), |
| 1963 | reasonIfUnsupported); |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 1964 | } |
| 1965 | |
Keith Davis | 3ae3f97 | 2021-05-21 16:33:48 +0100 | [diff] [blame] | 1966 | bool RefLayerSupport::IsShapeSupported(const TensorInfo& input, |
| 1967 | const TensorInfo& output, |
| 1968 | Optional<std::string&> reasonIfUnsupported) const |
| 1969 | { |
| 1970 | IgnoreUnused(input); |
| 1971 | bool supported = true; |
| 1972 | |
| 1973 | std::array<DataType, 1> supportedTypes = |
| 1974 | { |
| 1975 | DataType::Signed32 |
| 1976 | }; |
| 1977 | |
| 1978 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1979 | "Reference Shape: output type not supported"); |
| 1980 | |
| 1981 | return supported; |
| 1982 | } |
| 1983 | |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 1984 | bool RefLayerSupport::IsSliceSupported(const TensorInfo& input, |
| 1985 | const TensorInfo& output, |
| 1986 | const SliceDescriptor& descriptor, |
| 1987 | Optional<std::string&> reasonIfUnsupported) const |
| 1988 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1989 | IgnoreUnused(descriptor); |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 1990 | bool supported = true; |
| 1991 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1992 | std::array<DataType, 5> supportedTypes = |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 1993 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1994 | DataType::BFloat16, |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 1995 | DataType::Float32, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1996 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1997 | DataType::QAsymmU8, |
| 1998 | DataType::QSymmS16 |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 1999 | }; |
| 2000 | |
| 2001 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2002 | "Reference Slice: input type not supported"); |
| 2003 | |
| 2004 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2005 | "Reference Slice: output type not supported"); |
| 2006 | |
| 2007 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2008 | "Reference Slice: input and output types are mismatched"); |
| 2009 | |
| 2010 | return supported; |
| 2011 | } |
| 2012 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2013 | bool RefLayerSupport::IsSoftmaxSupported(const TensorInfo& input, |
| 2014 | const TensorInfo& output, |
| 2015 | const SoftmaxDescriptor& descriptor, |
| 2016 | Optional<std::string&> reasonIfUnsupported) const |
| 2017 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2018 | IgnoreUnused(descriptor); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 2019 | bool supported = true; |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2020 | std::array<DataType,7> supportedTypes = |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 2021 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2022 | DataType::BFloat16, |
| 2023 | DataType::Float32, |
| 2024 | DataType::Float16, |
| 2025 | DataType::QSymmS8, |
| 2026 | DataType::QAsymmS8, |
| 2027 | DataType::QAsymmU8, |
| 2028 | DataType::QSymmS16 |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 2029 | }; |
| 2030 | |
| 2031 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 2032 | "Reference Softmax: output type not supported"); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 2033 | |
| 2034 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 2035 | "Reference Softmax: input type not supported"); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 2036 | |
| 2037 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 2038 | "Reference Softmax: input type not supported"); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 2039 | |
| 2040 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2041 | } |
| 2042 | |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 2043 | bool RefLayerSupport::IsSpaceToBatchNdSupported(const TensorInfo& input, |
| 2044 | const TensorInfo& output, |
| 2045 | const SpaceToBatchNdDescriptor& descriptor, |
| 2046 | Optional<std::string&> reasonIfUnsupported) const |
| 2047 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2048 | IgnoreUnused(descriptor); |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 2049 | bool supported = true; |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2050 | std::array<DataType,6> supportedTypes = |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 2051 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2052 | DataType::BFloat16, |
| 2053 | DataType::Float32, |
| 2054 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2055 | DataType::QAsymmS8, |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2056 | DataType::QAsymmU8, |
| 2057 | DataType::QSymmS16 |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 2058 | }; |
| 2059 | |
| 2060 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2061 | "Reference SpaceToBatchNd: input type not supported"); |
| 2062 | |
| 2063 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2064 | "Reference SpaceToBatchNd: output type not supported"); |
| 2065 | |
| 2066 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2067 | "Reference SpaceToBatchNd: input and output types are mismatched"); |
| 2068 | |
| 2069 | return supported; |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 2070 | } |
| 2071 | |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 2072 | bool RefLayerSupport::IsSpaceToDepthSupported(const TensorInfo& input, |
Keith Davis | 5191033 | 2019-06-26 15:28:43 +0100 | [diff] [blame] | 2073 | const TensorInfo& output, |
| 2074 | const SpaceToDepthDescriptor& descriptor, |
| 2075 | Optional<std::string&> reasonIfUnsupported) const |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 2076 | { |
| 2077 | |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2078 | IgnoreUnused(descriptor); |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 2079 | bool supported = true; |
| 2080 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2081 | std::array<DataType,6> supportedTypes = |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 2082 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2083 | DataType::BFloat16, |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 2084 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 2085 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2086 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2087 | DataType::QAsymmU8, |
| 2088 | DataType::QSymmS16 |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 2089 | }; |
| 2090 | |
| 2091 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2092 | "Reference SpaceToDepth: input type not supported"); |
| 2093 | |
| 2094 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2095 | "Reference SpaceToDepth: output type not supported"); |
| 2096 | |
| 2097 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2098 | "Reference SpaceToDepth: input and output types are mismatched"); |
| 2099 | |
| 2100 | return supported; |
| 2101 | } |
| 2102 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2103 | bool RefLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 2104 | const ViewsDescriptor& descriptor, |
| 2105 | Optional<std::string&> reasonIfUnsupported) const |
| 2106 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2107 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2108 | bool supported = true; |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2109 | std::array<DataType,6> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2110 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2111 | DataType::BFloat16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2112 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 2113 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2114 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2115 | DataType::QAsymmU8, |
| 2116 | DataType::QSymmS16 |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2117 | }; |
| 2118 | |
| 2119 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2120 | "Reference splitter: input type not supported"); |
| 2121 | |
| 2122 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2123 | } |
| 2124 | |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 2125 | bool RefLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 2126 | const std::vector<std::reference_wrapper<TensorInfo>>& outputs, |
| 2127 | const ViewsDescriptor& descriptor, |
| 2128 | Optional<std::string&> reasonIfUnsupported) const |
| 2129 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2130 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2131 | bool supported = true; |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2132 | std::array<DataType,6> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2133 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2134 | DataType::BFloat16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2135 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 2136 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2137 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2138 | DataType::QAsymmU8, |
| 2139 | DataType::QSymmS16 |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2140 | }; |
| 2141 | |
| 2142 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2143 | "Reference splitter: output type not supported"); |
Derek Lamberti | eac4adb | 2020-08-25 13:05:59 +0100 | [diff] [blame] | 2144 | for (const TensorInfo& output : outputs) |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2145 | { |
| 2146 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2147 | "Reference splitter: input type not supported"); |
| 2148 | |
| 2149 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2150 | "Reference splitter: input and output types mismatched."); |
| 2151 | } |
| 2152 | |
| 2153 | return supported; |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 2154 | } |
| 2155 | |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 2156 | bool RefLayerSupport::IsStackSupported(const std::vector<const TensorInfo*>& inputs, |
| 2157 | const TensorInfo& output, |
| 2158 | const StackDescriptor& descriptor, |
| 2159 | Optional<std::string&> reasonIfUnsupported) const |
| 2160 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2161 | IgnoreUnused(descriptor); |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 2162 | |
| 2163 | bool supported = true; |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2164 | std::array<DataType,6> supportedTypes = |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 2165 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2166 | DataType::BFloat16, |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 2167 | DataType::Float32, |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 2168 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2169 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2170 | DataType::QAsymmU8, |
| 2171 | DataType::QSymmS16 |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 2172 | }; |
| 2173 | |
| 2174 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2175 | "Reference stack: output type not supported"); |
| 2176 | for (const TensorInfo* input : inputs) |
| 2177 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 2178 | ARMNN_ASSERT(input != nullptr); |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 2179 | supported &= CheckSupportRule(TypeAnyOf(*input, supportedTypes), reasonIfUnsupported, |
| 2180 | "Reference stack: input type not supported"); |
| 2181 | |
| 2182 | supported &= CheckSupportRule(TypesAreEqual(*input, output), reasonIfUnsupported, |
| 2183 | "Reference stack: input and output types mismatched."); |
| 2184 | } |
| 2185 | |
| 2186 | return supported; |
| 2187 | } |
| 2188 | |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 2189 | bool RefLayerSupport::IsStridedSliceSupported(const TensorInfo& input, |
| 2190 | const TensorInfo& output, |
| 2191 | const StridedSliceDescriptor& descriptor, |
| 2192 | Optional<std::string&> reasonIfUnsupported) const |
| 2193 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2194 | IgnoreUnused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2195 | bool supported = true; |
| 2196 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2197 | std::array<DataType,5> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2198 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2199 | DataType::BFloat16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2200 | DataType::Float32, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2201 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2202 | DataType::QAsymmU8, |
| 2203 | DataType::QSymmS16 |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 2204 | }; |
| 2205 | |
| 2206 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2207 | "Reference StridedSlice: input type not supported"); |
| 2208 | |
| 2209 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2210 | "Reference StridedSlice: output type not supported"); |
| 2211 | |
| 2212 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2213 | "Reference StridedSlice: input and output types are mismatched"); |
| 2214 | |
| 2215 | return supported; |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 2216 | } |
| 2217 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2218 | bool RefLayerSupport::IsSubtractionSupported(const TensorInfo& input0, |
| 2219 | const TensorInfo& input1, |
| 2220 | const TensorInfo& output, |
| 2221 | Optional<std::string&> reasonIfUnsupported) const |
| 2222 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 2223 | bool supported = true; |
| 2224 | |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 2225 | std::array<DataType,7> supportedTypes = { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2226 | DataType::BFloat16, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 2227 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 2228 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2229 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2230 | DataType::QAsymmU8, |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 2231 | DataType::QSymmS16, |
| 2232 | DataType::Signed32 |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 2233 | }; |
| 2234 | |
| 2235 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 2236 | "Reference subtraction: input 0 is not a supported type."); |
| 2237 | |
| 2238 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 2239 | "Reference subtraction: input 1 is not a supported type."); |
| 2240 | |
| 2241 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2242 | "Reference subtraction: output is not a supported type."); |
| 2243 | |
| 2244 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 2245 | "Reference subtraction: input 0 and Input 1 types are mismatched"); |
| 2246 | |
| 2247 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 2248 | "Reference subtraction: input and output types are mismatched"); |
| 2249 | |
| 2250 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 2251 | "Reference subtraction: shapes are not suitable for implicit broadcast."); |
| 2252 | |
| 2253 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 2254 | } |
| 2255 | |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 2256 | bool RefLayerSupport::IsPreluSupported(const TensorInfo& input, |
| 2257 | const TensorInfo& alpha, |
| 2258 | const TensorInfo& output, |
| 2259 | Optional<std::string&> reasonIfUnsupported) const |
| 2260 | { |
| 2261 | bool supported = true; |
| 2262 | |
Teresa Charlin | 3940d8b | 2020-05-29 16:47:23 +0100 | [diff] [blame] | 2263 | std::array<DataType, 6> supportedTypes |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 2264 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2265 | DataType::BFloat16, |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 2266 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 2267 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2268 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2269 | DataType::QAsymmU8, |
Teresa Charlin | 3940d8b | 2020-05-29 16:47:23 +0100 | [diff] [blame] | 2270 | DataType::QSymmS16 |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 2271 | }; |
| 2272 | |
| 2273 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2274 | "PReLU: input is not a supported type."); |
| 2275 | |
| 2276 | supported &= CheckSupportRule(TypeAnyOf(alpha, supportedTypes), reasonIfUnsupported, |
| 2277 | "PReLU: alpha is not a supported type."); |
| 2278 | |
| 2279 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2280 | "PReLU: output is not a supported type."); |
| 2281 | |
| 2282 | supported &= CheckSupportRule(TypesAreEqual(input, alpha, output), reasonIfUnsupported, |
| 2283 | "PReLU: input, alpha and output types are mismatched"); |
| 2284 | |
| 2285 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input, alpha, output), reasonIfUnsupported, |
| 2286 | "PReLU: shapes are not suitable for implicit broadcast"); |
| 2287 | |
| 2288 | return supported; |
| 2289 | } |
| 2290 | |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 2291 | bool RefLayerSupport::IsTransposeConvolution2dSupported(const TensorInfo& input, |
| 2292 | const TensorInfo& output, |
| 2293 | const TransposeConvolution2dDescriptor& descriptor, |
| 2294 | const TensorInfo& weights, |
| 2295 | const Optional<TensorInfo>& biases, |
| 2296 | Optional<std::string&> reasonIfUnsupported) const |
| 2297 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2298 | IgnoreUnused(descriptor); |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 2299 | bool supported = true; |
| 2300 | |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2301 | std::array<DataType,7> supportedTypes = |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 2302 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2303 | DataType::BFloat16, |
| 2304 | DataType::Float32, |
| 2305 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2306 | DataType::QAsymmS8, |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2307 | DataType::QAsymmU8, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2308 | DataType::QSymmS8, |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2309 | DataType::QSymmS16 |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 2310 | }; |
| 2311 | |
| 2312 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2313 | "Reference TransposeConvolution2d: input is not a supported type."); |
| 2314 | |
| 2315 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2316 | "Reference TransposeConvolution2d: output is not a supported type."); |
| 2317 | |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 2318 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2319 | "Reference TransposeConvolution2d: input and output types mismatched."); |
| 2320 | |
Aron Virginas-Tar | 94d3b93 | 2019-11-11 12:54:47 +0000 | [diff] [blame] | 2321 | |
| 2322 | const DataType inputType = input.GetDataType(); |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2323 | if (IsQuantized8BitType(inputType)) |
Aron Virginas-Tar | 94d3b93 | 2019-11-11 12:54:47 +0000 | [diff] [blame] | 2324 | { |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 2325 | ARMNN_NO_DEPRECATE_WARN_BEGIN |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2326 | std::array<DataType, 4> supportedWeightTypes = |
Aron Virginas-Tar | 94d3b93 | 2019-11-11 12:54:47 +0000 | [diff] [blame] | 2327 | { |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2328 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2329 | DataType::QAsymmU8, |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 2330 | DataType::QSymmS8, |
| 2331 | DataType::QuantizedSymm8PerAxis //Deprecated |
Aron Virginas-Tar | 94d3b93 | 2019-11-11 12:54:47 +0000 | [diff] [blame] | 2332 | }; |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 2333 | ARMNN_NO_DEPRECATE_WARN_END |
Aron Virginas-Tar | 94d3b93 | 2019-11-11 12:54:47 +0000 | [diff] [blame] | 2334 | |
| 2335 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedWeightTypes), reasonIfUnsupported, |
| 2336 | "Reference TransposeConvolution2d: weights type not supported for " |
| 2337 | "quantized input."); |
| 2338 | } |
| 2339 | else |
| 2340 | { |
| 2341 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 2342 | "Reference TransposeConvolution2d: weights is not a supported type."); |
| 2343 | |
| 2344 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 2345 | "Reference TransposeConvolution2d: input and weights types mismatched."); |
| 2346 | } |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 2347 | |
| 2348 | if (biases.has_value()) |
| 2349 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2350 | std::array<DataType,4> biasesSupportedTypes = |
Aron Virginas-Tar | 651aafe | 2019-08-05 11:52:05 +0100 | [diff] [blame] | 2351 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2352 | DataType::BFloat16, |
| 2353 | DataType::Float32, |
| 2354 | DataType::Float16, |
| 2355 | DataType::Signed32 |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 2356 | }; |
| 2357 | supported &= CheckSupportRule(TypeAnyOf(biases.value(), biasesSupportedTypes), reasonIfUnsupported, |
| 2358 | "Reference TransposeConvolution2d: biases is not a supported type."); |
| 2359 | } |
| 2360 | |
| 2361 | return supported; |
| 2362 | } |
| 2363 | |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 2364 | bool RefLayerSupport::IsTransposeSupported(const TensorInfo& input, |
| 2365 | const TensorInfo& output, |
| 2366 | const TransposeDescriptor& descriptor, |
| 2367 | Optional<std::string&> reasonIfUnsupported) const |
| 2368 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2369 | IgnoreUnused(descriptor); |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 2370 | bool supported = true; |
| 2371 | |
| 2372 | // Define supported output and inputs types. |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2373 | std::array<DataType, 6> supportedTypes = |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 2374 | { |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2375 | DataType::BFloat16, |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 2376 | DataType::Float32, |
| 2377 | DataType::Float16, |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 2378 | DataType::QAsymmS8, |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 2379 | DataType::QAsymmU8, |
| 2380 | DataType::QSymmS16 |
| 2381 | }; |
| 2382 | |
| 2383 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2384 | "Reference transpose: input is not a supported type."); |
| 2385 | |
| 2386 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 2387 | "Reference transpose: output is not a supported type."); |
| 2388 | |
| 2389 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2390 | "Reference transpose: input and output types are mismatched."); |
| 2391 | |
| 2392 | return supported; |
| 2393 | } |
| 2394 | |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2395 | bool RefLayerSupport::IsUnidirectionalSequenceLstmSupported( |
| 2396 | const TensorInfo& input, |
| 2397 | const TensorInfo& outputStateIn, |
| 2398 | const TensorInfo& cellStateIn, |
| 2399 | const TensorInfo& output, |
| 2400 | const Optional<TensorInfo>& hiddenStateOutput, |
| 2401 | const Optional<TensorInfo>& cellStateOutput, |
| 2402 | const UnidirectionalSequenceLstmDescriptor& descriptor, |
| 2403 | const LstmInputParamsInfo& paramsInfo, |
| 2404 | Optional<std::string&> reasonIfUnsupported) const |
| 2405 | { |
| 2406 | IgnoreUnused(descriptor); |
| 2407 | IgnoreUnused(paramsInfo); |
| 2408 | IgnoreUnused(outputStateIn); |
| 2409 | IgnoreUnused(cellStateIn); |
| 2410 | bool supported = true; |
| 2411 | |
| 2412 | if (hiddenStateOutput.has_value() || cellStateOutput.has_value()) |
| 2413 | { |
| 2414 | reasonIfUnsupported.value() += "Reference UnidirectionalSequenceLstm: hidden state output " |
| 2415 | "and cell state output are not supported at the moment."; |
| 2416 | } |
| 2417 | |
| 2418 | std::array<DataType, 1> supportedTypes = |
| 2419 | { |
| 2420 | DataType::Float32 |
| 2421 | }; |
| 2422 | |
Narumol Prangnawarat | bd575b2 | 2021-08-31 16:53:54 +0100 | [diff] [blame] | 2423 | std::array<DataType, 2> supportedWeightTypes = |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2424 | { |
Narumol Prangnawarat | bd575b2 | 2021-08-31 16:53:54 +0100 | [diff] [blame] | 2425 | DataType::Float32, |
| 2426 | DataType::QAsymmS8 |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 2427 | }; |
| 2428 | |
| 2429 | // check inputs and outputs |
| 2430 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 2431 | "Reference UnidirectionalSequenceLstm: input is not a supported type."); |
| 2432 | supported &= CheckSupportRule(TypesAreEqual(input, outputStateIn), reasonIfUnsupported, |
| 2433 | "Reference UnidirectionalSequenceLstm: input and outputStateIn types are mismatched"); |
| 2434 | supported &= CheckSupportRule(TypesAreEqual(input, cellStateIn), reasonIfUnsupported, |
| 2435 | "Reference UnidirectionalSequenceLstm: input and cellStateIn types are mismatched"); |
| 2436 | |
| 2437 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 2438 | "Reference UnidirectionalSequenceLstm: input and output types are mismatched"); |
| 2439 | // check layer parameters |
| 2440 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetInputToForgetWeights(), supportedWeightTypes), |
| 2441 | reasonIfUnsupported, |
| 2442 | "Reference UnidirectionalSequenceLstm: InputToForgetWeights " |
| 2443 | "is not a supported type."); |
| 2444 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetInputToCellWeights(), supportedWeightTypes), |
| 2445 | reasonIfUnsupported, |
| 2446 | "Reference UnidirectionalSequenceLstm: InputToCellWeights is not a supported type."); |
| 2447 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetInputToOutputWeights(), supportedWeightTypes), |
| 2448 | reasonIfUnsupported, |
| 2449 | "Reference UnidirectionalSequenceLstm: InputToOutputWeights " |
| 2450 | "is not a supported type."); |
| 2451 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetRecurrentToForgetWeights(), supportedWeightTypes), |
| 2452 | reasonIfUnsupported, |
| 2453 | "Reference UnidirectionalSequenceLstm: RecurrentToForgetWeights " |
| 2454 | "is not a supported type."); |
| 2455 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetRecurrentToCellWeights(), supportedWeightTypes), |
| 2456 | reasonIfUnsupported, |
| 2457 | "Reference UnidirectionalSequenceLstm: RecurrentToCellWeights " |
| 2458 | "is not a supported type."); |
| 2459 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetRecurrentToOutputWeights(), supportedWeightTypes), |
| 2460 | reasonIfUnsupported, |
| 2461 | "Reference UnidirectionalSequenceLstm: RecurrentToOutputWeights " |
| 2462 | "is not a supported type."); |
| 2463 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetForgetGateBias()), reasonIfUnsupported, |
| 2464 | "Reference UnidirectionalSequenceLstm: input and ForgetGateBias types " |
| 2465 | "are mismatched"); |
| 2466 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellBias()), reasonIfUnsupported, |
| 2467 | "Reference UnidirectionalSequenceLstm: input and CellBias types are mismatched"); |
| 2468 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetOutputGateBias()), reasonIfUnsupported, |
| 2469 | "Reference UnidirectionalSequenceLstm: input and OutputGateBias types " |
| 2470 | "are mismatched"); |
| 2471 | if (!descriptor.m_CifgEnabled) |
| 2472 | { |
| 2473 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetInputToInputWeights(), supportedWeightTypes), |
| 2474 | reasonIfUnsupported, |
| 2475 | "Reference UnidirectionalSequenceLstm: InputToInputWeights " |
| 2476 | "is not a supported type."); |
| 2477 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetRecurrentToInputWeights(), supportedWeightTypes), |
| 2478 | reasonIfUnsupported, |
| 2479 | "Reference UnidirectionalSequenceLstm: RecurrentToInputWeights " |
| 2480 | "is not a supported type."); |
| 2481 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputGateBias()), reasonIfUnsupported, |
| 2482 | "Reference UnidirectionalSequenceLstm: input and InputGateBias types " |
| 2483 | "are mismatched"); |
| 2484 | if (descriptor.m_PeepholeEnabled) |
| 2485 | { |
| 2486 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetCellToInputWeights(), supportedWeightTypes), |
| 2487 | reasonIfUnsupported, |
| 2488 | "Reference UnidirectionalSequenceLstm: CellToInputWeights " |
| 2489 | "is not a supported type."); |
| 2490 | } |
| 2491 | } |
| 2492 | if (descriptor.m_PeepholeEnabled) |
| 2493 | { |
| 2494 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetCellToForgetWeights(), supportedWeightTypes), |
| 2495 | reasonIfUnsupported, |
| 2496 | "Reference UnidirectionalSequenceLstm: CellToForgetWeights " |
| 2497 | "is not a supported type."); |
| 2498 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetCellToOutputWeights(), supportedWeightTypes), |
| 2499 | reasonIfUnsupported, |
| 2500 | "Reference UnidirectionalSequenceLstm: CellToOutputWeights " |
| 2501 | "is not a supported type."); |
| 2502 | } |
| 2503 | if (descriptor.m_ProjectionEnabled) |
| 2504 | { |
| 2505 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetProjectionWeights(), supportedWeightTypes), |
| 2506 | reasonIfUnsupported, |
| 2507 | "Reference UnidirectionalSequenceLstm: ProjectionWeights " |
| 2508 | "is not a supported type."); |
| 2509 | if (paramsInfo.m_ProjectionBias != nullptr) |
| 2510 | { |
| 2511 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetProjectionBias()), reasonIfUnsupported, |
| 2512 | "Reference UnidirectionalSequenceLstm: input and ProjectionBias types " |
| 2513 | "are mismatched"); |
| 2514 | } |
| 2515 | } |
| 2516 | if (descriptor.m_LayerNormEnabled) |
| 2517 | { |
| 2518 | if (!descriptor.m_CifgEnabled) |
| 2519 | { |
| 2520 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetInputLayerNormWeights(), supportedWeightTypes), |
| 2521 | reasonIfUnsupported, |
| 2522 | "Reference UnidirectionalSequenceLstm: InputLayerNormWeights " |
| 2523 | "is not a supported type."); |
| 2524 | } |
| 2525 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetForgetLayerNormWeights(), supportedWeightTypes), |
| 2526 | reasonIfUnsupported, |
| 2527 | "Reference UnidirectionalSequenceLstm: ForgetLayerNormWeights " |
| 2528 | "is not a supported type."); |
| 2529 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetCellLayerNormWeights(), supportedWeightTypes), |
| 2530 | reasonIfUnsupported, |
| 2531 | "Reference UnidirectionalSequenceLstm: CellLayerNormWeights " |
| 2532 | "is not a supported type."); |
| 2533 | supported &= CheckSupportRule(TypeAnyOf(paramsInfo.GetOutputLayerNormWeights(), supportedWeightTypes), |
| 2534 | reasonIfUnsupported, |
| 2535 | "Reference UnidirectionalSequenceLstm: OutputLayerNormWeights " |
| 2536 | "is not a supported type."); |
| 2537 | } |
| 2538 | |
| 2539 | return supported; |
| 2540 | } |
| 2541 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 2542 | } // namespace armnn |