Francis Murtagh | 9270d9e | 2022-08-12 13:54:17 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2022 Arm Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | |
| 7 | #include <armnn/Optional.hpp> |
| 8 | #include <armnn/Types.hpp> |
| 9 | #include <tosaReference/TosaRefLayerSupport.hpp> |
| 10 | |
| 11 | #include <doctest/doctest.h> |
| 12 | |
| 13 | #include <string> |
| 14 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 15 | using namespace armnn; |
| 16 | |
Francis Murtagh | 9270d9e | 2022-08-12 13:54:17 +0100 | [diff] [blame] | 17 | TEST_SUITE("TosaRefLayerSupported") |
| 18 | { |
| 19 | |
| 20 | TEST_CASE("IsLayerSupportedTosaReferenceAddition") |
| 21 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 22 | TensorShape shape0 = {1,1,3,4}; |
| 23 | TensorShape shape1 = {4}; |
| 24 | TensorShape outShape = {1,1,3,4}; |
| 25 | TensorInfo in0(shape0, DataType::Float32); |
| 26 | TensorInfo in1(shape1, DataType::Float32); |
| 27 | TensorInfo out(outShape, DataType::Float32); |
Francis Murtagh | 9270d9e | 2022-08-12 13:54:17 +0100 | [diff] [blame] | 28 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 29 | BaseDescriptor desc; |
| 30 | TosaRefLayerSupport supportChecker; |
Francis Murtagh | 9270d9e | 2022-08-12 13:54:17 +0100 | [diff] [blame] | 31 | std::string reasonIfNotSupported; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 32 | auto supported = supportChecker.IsLayerSupported(LayerType::Addition, |
Francis Murtagh | 9270d9e | 2022-08-12 13:54:17 +0100 | [diff] [blame] | 33 | {in0, in1, out}, |
| 34 | desc, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 35 | EmptyOptional(), |
| 36 | EmptyOptional(), |
Francis Murtagh | 9270d9e | 2022-08-12 13:54:17 +0100 | [diff] [blame] | 37 | reasonIfNotSupported); |
| 38 | |
| 39 | CHECK(supported); |
| 40 | } |
| 41 | |
| 42 | TEST_CASE("IsLayerSupportedTosaReferenceAdditionUnsupported") |
| 43 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 44 | TensorShape shape0 = {1,1,3,4}; |
| 45 | TensorShape shape1 = {4}; |
| 46 | TensorShape outShape = {1,1,3,4}; |
| 47 | TensorInfo in0(shape0, DataType::Signed64); |
| 48 | TensorInfo in1(shape1, DataType::Signed64); |
| 49 | TensorInfo out(outShape, DataType::Signed64); |
Francis Murtagh | 9270d9e | 2022-08-12 13:54:17 +0100 | [diff] [blame] | 50 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 51 | BaseDescriptor desc; |
| 52 | TosaRefLayerSupport supportChecker; |
Francis Murtagh | 9270d9e | 2022-08-12 13:54:17 +0100 | [diff] [blame] | 53 | std::string reasonIfNotSupported; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 54 | auto supported = supportChecker.IsLayerSupported(LayerType::Addition, |
Francis Murtagh | 9270d9e | 2022-08-12 13:54:17 +0100 | [diff] [blame] | 55 | {in0, in1, out}, |
| 56 | desc, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 57 | EmptyOptional(), |
| 58 | EmptyOptional(), |
Francis Murtagh | 9270d9e | 2022-08-12 13:54:17 +0100 | [diff] [blame] | 59 | reasonIfNotSupported); |
| 60 | |
| 61 | CHECK(!supported); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 62 | REQUIRE(reasonIfNotSupported.find( |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 63 | "TOSA Reference Operator: Op_ADD for input: input0_") != std::string::npos); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 64 | REQUIRE(reasonIfNotSupported.find( |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 65 | "TOSA Reference Operator: Op_ADD for input: input1_") != std::string::npos); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 66 | REQUIRE(reasonIfNotSupported.find( |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 67 | "TOSA Reference Operator: Op_ADD for output: output0_") != std::string::npos); |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 68 | REQUIRE(reasonIfNotSupported.find( |
| 69 | "has an unsupported data type: DType_UNKNOWN") != std::string::npos); |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | TEST_CASE("IsLayerSupportedTosaReferenceConstant") |
| 73 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 74 | TensorInfo outputInfo({1,1,3,4}, DataType::Float32); |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 75 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 76 | TosaRefLayerSupport supportChecker; |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 77 | std::string reasonIfNotSupported; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 78 | auto supported = supportChecker.IsLayerSupported(LayerType::Constant, |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 79 | {outputInfo}, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 80 | BaseDescriptor(), |
| 81 | EmptyOptional(), |
| 82 | EmptyOptional(), |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 83 | reasonIfNotSupported); |
| 84 | |
| 85 | CHECK(supported); |
| 86 | } |
| 87 | |
| 88 | TEST_CASE("IsLayerSupportedTosaReferenceConstantUnsupported") |
| 89 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 90 | TensorInfo outputInfo({1,1,3,4}, DataType::Signed64); |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 91 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 92 | TosaRefLayerSupport supportChecker; |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 93 | std::string reasonIfNotSupported; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 94 | auto supported = supportChecker.IsLayerSupported(LayerType::Constant, |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 95 | {outputInfo}, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 96 | BaseDescriptor(), |
| 97 | EmptyOptional(), |
| 98 | EmptyOptional(), |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 99 | reasonIfNotSupported); |
| 100 | |
| 101 | CHECK(!supported); |
| 102 | REQUIRE(reasonIfNotSupported.find( |
| 103 | "TOSA Reference Operator: Op_CONST for output: constant_") != std::string::npos); |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 104 | REQUIRE(reasonIfNotSupported.find( |
| 105 | "has an unsupported data type: DType_UNKNOWN") != std::string::npos); |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | TEST_CASE("IsLayerSupportedTosaReferenceConv2d") |
| 109 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 110 | TensorInfo inputInfo ({ 1, 5, 5, 1 }, DataType::Float32); |
| 111 | TensorInfo outputInfo({ 1, 3, 3, 1 }, DataType::Float32); |
| 112 | TensorInfo weightsInfo({ 1, 3, 3, 1 }, DataType::Float32); |
| 113 | TensorInfo biasesInfo ({ 1 }, DataType::Float32); |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 114 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 115 | Convolution2dDescriptor desc; |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 116 | desc.m_BiasEnabled = true; |
| 117 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 118 | TosaRefLayerSupport supportChecker; |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 119 | std::string reasonIfNotSupported; |
| 120 | auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Convolution2d, |
| 121 | {inputInfo, outputInfo, weightsInfo, biasesInfo}, |
| 122 | desc, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 123 | EmptyOptional(), |
| 124 | EmptyOptional(), |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 125 | reasonIfNotSupported); |
| 126 | |
| 127 | CHECK(supported); |
| 128 | } |
| 129 | |
| 130 | TEST_CASE("IsLayerSupportedTosaReferenceConv2dUnsupported") |
| 131 | { |
| 132 | // If inputs and weights are Fp32, output must match. |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 133 | TensorInfo inputInfo ({ 1, 5, 5, 1 }, DataType::Float32); |
| 134 | TensorInfo outputInfo({ 1, 3, 3, 1 }, DataType::Signed64); |
| 135 | TensorInfo weightsInfo({ 1, 3, 3, 1 }, DataType::Float32, 0.0f, 0, true); |
| 136 | TensorInfo biasesInfo ({ 1 }, DataType::Float32, 0.0f, 0, true); |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 137 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 138 | Convolution2dDescriptor desc; |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 139 | desc.m_BiasEnabled = true; |
| 140 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 141 | TosaRefLayerSupport supportChecker; |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 142 | std::string reasonIfNotSupported; |
| 143 | auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Convolution2d, |
| 144 | {inputInfo, outputInfo, weightsInfo, biasesInfo}, |
| 145 | desc, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 146 | EmptyOptional(), |
| 147 | EmptyOptional(), |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 148 | reasonIfNotSupported); |
| 149 | |
| 150 | CHECK(!supported); |
| 151 | REQUIRE(reasonIfNotSupported.find( |
| 152 | "TOSA Reference Operator: Op_CONV2D for input 0: input0_") != std::string::npos); |
| 153 | REQUIRE(reasonIfNotSupported.find( |
| 154 | "input 1: input1_") != std::string::npos); |
| 155 | REQUIRE(reasonIfNotSupported.find( |
| 156 | "and output: output0_") != std::string::npos); |
| 157 | REQUIRE(reasonIfNotSupported.find( |
| 158 | "has an unsupported input data type combination.") != std::string::npos); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | TEST_CASE("IsLayerSupportedTosaReferenceMaxPooling2d") |
| 162 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 163 | TensorShape inShape = {1,1,3,4}; |
| 164 | TensorShape outShape = {1,1,3,4}; |
| 165 | TensorInfo in(inShape, DataType::Float32); |
| 166 | TensorInfo out(outShape, DataType::Float32); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 167 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 168 | Pooling2dDescriptor desc; |
| 169 | TosaRefLayerSupport supportChecker; |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 170 | std::string reasonIfNotSupported; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 171 | auto supported = supportChecker.IsLayerSupported(LayerType::Pooling2d, |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 172 | {in, out}, |
| 173 | desc, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 174 | EmptyOptional(), |
| 175 | EmptyOptional(), |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 176 | reasonIfNotSupported); |
| 177 | |
| 178 | CHECK(supported); |
| 179 | } |
| 180 | |
| 181 | TEST_CASE("IsLayerSupportedTosaReferenceAvgPooling2d_IgnoreValue") |
| 182 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 183 | TensorShape inShape = {1,1,3,4}; |
| 184 | TensorShape outShape = {1,1,3,4}; |
| 185 | TensorInfo in(inShape, DataType::Float32); |
| 186 | TensorInfo out(outShape, DataType::Float32); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 187 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 188 | Pooling2dDescriptor desc; |
| 189 | desc.m_PaddingMethod = PaddingMethod::IgnoreValue; |
| 190 | desc.m_PoolType = PoolingAlgorithm::Average; |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 191 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 192 | TosaRefLayerSupport supportChecker; |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 193 | std::string reasonIfNotSupported; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 194 | auto supported = supportChecker.IsLayerSupported(LayerType::Pooling2d, |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 195 | {in, out}, |
| 196 | desc, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 197 | EmptyOptional(), |
| 198 | EmptyOptional(), |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 199 | reasonIfNotSupported); |
| 200 | |
| 201 | CHECK(supported); |
| 202 | } |
| 203 | |
| 204 | TEST_CASE("IsLayerSupportedTosaReferenceAvgPooling2d_InputOutputDatatypeDifferent") |
| 205 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 206 | TensorShape inShape = {1,1,3,4}; |
| 207 | TensorShape outShape = {1,1,3,4}; |
| 208 | TensorInfo in(inShape, DataType::QAsymmS8); |
| 209 | TensorInfo out(outShape, DataType::Signed32); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 210 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 211 | Pooling2dDescriptor desc; |
| 212 | desc.m_PaddingMethod = PaddingMethod::IgnoreValue; |
| 213 | desc.m_PoolType = PoolingAlgorithm::Average; |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 214 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 215 | TosaRefLayerSupport supportChecker; |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 216 | std::string reasonIfNotSupported; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 217 | auto supported = supportChecker.IsLayerSupported(LayerType::Pooling2d, |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 218 | {in, out}, |
| 219 | desc, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 220 | EmptyOptional(), |
| 221 | EmptyOptional(), |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 222 | reasonIfNotSupported); |
| 223 | |
| 224 | CHECK(supported); |
| 225 | } |
| 226 | |
| 227 | TEST_CASE("IsLayerSupportedTosaReferenceMaxPooling2dUnsupported") |
| 228 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 229 | TensorShape inShape = {1,1,3,4}; |
| 230 | TensorShape outShape = {1,1,3,4}; |
| 231 | TensorInfo in(inShape, DataType::Signed64); |
| 232 | TensorInfo out(outShape, DataType::Signed64); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 233 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 234 | Pooling2dDescriptor desc; |
| 235 | TosaRefLayerSupport supportChecker; |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 236 | std::string reasonIfNotSupported; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 237 | auto supported = supportChecker.IsLayerSupported(LayerType::Pooling2d, |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 238 | {in, out}, |
| 239 | desc, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 240 | EmptyOptional(), |
| 241 | EmptyOptional(), |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 242 | reasonIfNotSupported); |
| 243 | |
| 244 | CHECK(!supported); |
| 245 | REQUIRE(reasonIfNotSupported.find( |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 246 | "TOSA Reference Operator: Op_MAX_POOL2D for input: input0_") != std::string::npos); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 247 | REQUIRE(reasonIfNotSupported.find( |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 248 | "TOSA Reference Operator: Op_MAX_POOL2D for output: output0_") != std::string::npos); |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 249 | REQUIRE(reasonIfNotSupported.find( |
| 250 | "has an unsupported data type: DType_UNKNOWN") != std::string::npos); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | TEST_CASE("IsLayerSupportedTosaReferenceAvgPooling2dUnsupported_InputOutputDatatypeDifferent") |
| 254 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 255 | TensorShape inShape = {1,1,3,4}; |
| 256 | TensorShape outShape = {1,1,3,4}; |
| 257 | TensorInfo in(inShape, DataType::Float32); |
| 258 | TensorInfo out(outShape, DataType::Float16); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 259 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 260 | Pooling2dDescriptor desc; |
| 261 | desc.m_PaddingMethod = PaddingMethod::IgnoreValue; |
| 262 | desc.m_PoolType = PoolingAlgorithm::Average; |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 263 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 264 | TosaRefLayerSupport supportChecker; |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 265 | std::string reasonIfNotSupported; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 266 | auto supported = supportChecker.IsLayerSupported(LayerType::Pooling2d, |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 267 | {in, out}, |
| 268 | desc, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 269 | EmptyOptional(), |
| 270 | EmptyOptional(), |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 271 | reasonIfNotSupported); |
| 272 | |
| 273 | CHECK(!supported); |
| 274 | REQUIRE(reasonIfNotSupported.find( |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 275 | "TOSA Reference Operator: Op_AVG_POOL2D for input: intermediate0_") != std::string::npos); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 276 | REQUIRE(reasonIfNotSupported.find( |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 277 | " and output: output0_") != std::string::npos); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 278 | REQUIRE(reasonIfNotSupported.find( |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 279 | " has an unsupported input data type: DType_FP32 to output data type: DType_FP16") != std::string::npos); |
| 280 | } |
| 281 | |
| 282 | TEST_CASE("IsLayerSupportedTosaReferenceReshape") |
| 283 | { |
| 284 | TensorShape inShape = {3,4}; |
| 285 | TensorShape outShape = {12}; |
| 286 | TensorInfo in(inShape, DataType::Float32); |
| 287 | TensorInfo out(outShape, DataType::Float32); |
| 288 | |
| 289 | ReshapeDescriptor desc; |
| 290 | desc.m_TargetShape = {12}; |
| 291 | |
| 292 | TosaRefLayerSupport supportChecker; |
| 293 | std::string reasonIfNotSupported; |
| 294 | auto supported = supportChecker.IsLayerSupported(LayerType::Reshape, |
| 295 | {in, out}, |
| 296 | desc, |
| 297 | EmptyOptional(), |
| 298 | EmptyOptional(), |
| 299 | reasonIfNotSupported); |
| 300 | |
| 301 | CHECK(supported); |
| 302 | } |
| 303 | |
| 304 | TEST_CASE("IsLayerSupportedTosaReferenceReshapeUnsupported") |
| 305 | { |
| 306 | TensorShape inShape = {3,4}; |
| 307 | TensorShape outShape = {12}; |
| 308 | TensorInfo in(inShape, DataType::Signed64); |
| 309 | TensorInfo out(outShape, DataType::Signed64); |
| 310 | |
| 311 | ReshapeDescriptor desc; |
| 312 | desc.m_TargetShape = {12}; |
| 313 | |
| 314 | TosaRefLayerSupport supportChecker; |
| 315 | std::string reasonIfNotSupported; |
| 316 | auto supported = supportChecker.IsLayerSupported(LayerType::Reshape, |
| 317 | {in, out}, |
| 318 | desc, |
| 319 | EmptyOptional(), |
| 320 | EmptyOptional(), |
| 321 | reasonIfNotSupported); |
| 322 | |
| 323 | CHECK(!supported); |
| 324 | REQUIRE(reasonIfNotSupported.find( |
| 325 | "TOSA Reference Operator: Op_RESHAPE for input: input0_") != std::string::npos); |
| 326 | REQUIRE(reasonIfNotSupported.find( |
| 327 | "TOSA Reference Operator: Op_RESHAPE for output: output0_") != std::string::npos); |
| 328 | REQUIRE(reasonIfNotSupported.find( |
| 329 | "has an unsupported data type: DType_UNKNOWN") != std::string::npos); |
Francis Murtagh | 9270d9e | 2022-08-12 13:54:17 +0100 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | } |