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