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}; |
Matthew Sloyan | 67fd526 | 2022-12-07 19:28:18 +0000 | [diff] [blame] | 23 | TensorShape shape1 = {1,1,3,4}; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 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); |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | TEST_CASE("IsLayerSupportedTosaReferenceConstant") |
| 65 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 66 | TensorInfo outputInfo({1,1,3,4}, DataType::Float32); |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 67 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 68 | TosaRefLayerSupport supportChecker; |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 69 | std::string reasonIfNotSupported; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 70 | auto supported = supportChecker.IsLayerSupported(LayerType::Constant, |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 71 | {outputInfo}, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 72 | BaseDescriptor(), |
| 73 | EmptyOptional(), |
| 74 | EmptyOptional(), |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 75 | reasonIfNotSupported); |
| 76 | |
| 77 | CHECK(supported); |
| 78 | } |
| 79 | |
| 80 | TEST_CASE("IsLayerSupportedTosaReferenceConstantUnsupported") |
| 81 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 82 | TensorInfo outputInfo({1,1,3,4}, DataType::Signed64); |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 83 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 84 | TosaRefLayerSupport supportChecker; |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 85 | std::string reasonIfNotSupported; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 86 | auto supported = supportChecker.IsLayerSupported(LayerType::Constant, |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 87 | {outputInfo}, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 88 | BaseDescriptor(), |
| 89 | EmptyOptional(), |
| 90 | EmptyOptional(), |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 91 | reasonIfNotSupported); |
| 92 | |
| 93 | CHECK(!supported); |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | TEST_CASE("IsLayerSupportedTosaReferenceConv2d") |
| 97 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 98 | TensorInfo inputInfo ({ 1, 5, 5, 1 }, DataType::Float32); |
| 99 | TensorInfo outputInfo({ 1, 3, 3, 1 }, DataType::Float32); |
| 100 | TensorInfo weightsInfo({ 1, 3, 3, 1 }, DataType::Float32); |
| 101 | TensorInfo biasesInfo ({ 1 }, DataType::Float32); |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 102 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 103 | Convolution2dDescriptor desc; |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 104 | desc.m_BiasEnabled = true; |
| 105 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 106 | TosaRefLayerSupport supportChecker; |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 107 | std::string reasonIfNotSupported; |
Matthew Sloyan | fc9d5e7 | 2022-12-08 13:38:23 +0000 | [diff] [blame^] | 108 | auto supported = supportChecker.IsLayerSupported(LayerType::Convolution2d, |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 109 | {inputInfo, outputInfo, weightsInfo, biasesInfo}, |
| 110 | desc, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 111 | EmptyOptional(), |
| 112 | EmptyOptional(), |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 113 | reasonIfNotSupported); |
| 114 | |
| 115 | CHECK(supported); |
| 116 | } |
| 117 | |
| 118 | TEST_CASE("IsLayerSupportedTosaReferenceConv2dUnsupported") |
| 119 | { |
| 120 | // If inputs and weights are Fp32, output must match. |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 121 | TensorInfo inputInfo ({ 1, 5, 5, 1 }, DataType::Float32); |
| 122 | TensorInfo outputInfo({ 1, 3, 3, 1 }, DataType::Signed64); |
| 123 | TensorInfo weightsInfo({ 1, 3, 3, 1 }, DataType::Float32, 0.0f, 0, true); |
| 124 | TensorInfo biasesInfo ({ 1 }, DataType::Float32, 0.0f, 0, true); |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 125 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 126 | Convolution2dDescriptor desc; |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 127 | desc.m_BiasEnabled = true; |
| 128 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 129 | TosaRefLayerSupport supportChecker; |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 130 | std::string reasonIfNotSupported; |
Matthew Sloyan | fc9d5e7 | 2022-12-08 13:38:23 +0000 | [diff] [blame^] | 131 | auto supported = supportChecker.IsLayerSupported(LayerType::Convolution2d, |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 132 | {inputInfo, outputInfo, weightsInfo, biasesInfo}, |
| 133 | desc, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 134 | EmptyOptional(), |
| 135 | EmptyOptional(), |
Matthew Sloyan | c5fe6e7 | 2022-11-25 16:10:00 +0000 | [diff] [blame] | 136 | reasonIfNotSupported); |
| 137 | |
| 138 | CHECK(!supported); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | TEST_CASE("IsLayerSupportedTosaReferenceMaxPooling2d") |
| 142 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 143 | TensorShape inShape = {1,1,3,4}; |
| 144 | TensorShape outShape = {1,1,3,4}; |
| 145 | TensorInfo in(inShape, DataType::Float32); |
| 146 | TensorInfo out(outShape, DataType::Float32); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 147 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 148 | Pooling2dDescriptor desc; |
Matthew Sloyan | 67fd526 | 2022-12-07 19:28:18 +0000 | [diff] [blame] | 149 | desc.m_PoolHeight = 1; |
| 150 | desc.m_PoolWidth = 1; |
| 151 | desc.m_StrideX = 1; |
| 152 | desc.m_StrideY = 1; |
Matthew Sloyan | fc9d5e7 | 2022-12-08 13:38:23 +0000 | [diff] [blame^] | 153 | desc.m_PoolType = PoolingAlgorithm::Max; |
Matthew Sloyan | 67fd526 | 2022-12-07 19:28:18 +0000 | [diff] [blame] | 154 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 155 | TosaRefLayerSupport supportChecker; |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 156 | std::string reasonIfNotSupported; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 157 | auto supported = supportChecker.IsLayerSupported(LayerType::Pooling2d, |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 158 | {in, out}, |
| 159 | desc, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 160 | EmptyOptional(), |
| 161 | EmptyOptional(), |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 162 | reasonIfNotSupported); |
| 163 | |
| 164 | CHECK(supported); |
| 165 | } |
| 166 | |
| 167 | TEST_CASE("IsLayerSupportedTosaReferenceAvgPooling2d_IgnoreValue") |
| 168 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 169 | TensorShape inShape = {1,1,3,4}; |
| 170 | TensorShape outShape = {1,1,3,4}; |
| 171 | TensorInfo in(inShape, DataType::Float32); |
| 172 | TensorInfo out(outShape, DataType::Float32); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 173 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 174 | Pooling2dDescriptor desc; |
Matthew Sloyan | 67fd526 | 2022-12-07 19:28:18 +0000 | [diff] [blame] | 175 | desc.m_PoolHeight = 1; |
| 176 | desc.m_PoolWidth = 1; |
| 177 | desc.m_StrideX = 1; |
| 178 | desc.m_StrideY = 1; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 179 | desc.m_PaddingMethod = PaddingMethod::IgnoreValue; |
| 180 | desc.m_PoolType = PoolingAlgorithm::Average; |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 181 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 182 | TosaRefLayerSupport supportChecker; |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 183 | std::string reasonIfNotSupported; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 184 | auto supported = supportChecker.IsLayerSupported(LayerType::Pooling2d, |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 185 | {in, out}, |
| 186 | desc, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 187 | EmptyOptional(), |
| 188 | EmptyOptional(), |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 189 | reasonIfNotSupported); |
| 190 | |
| 191 | CHECK(supported); |
| 192 | } |
| 193 | |
| 194 | TEST_CASE("IsLayerSupportedTosaReferenceMaxPooling2dUnsupported") |
| 195 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 196 | TensorShape inShape = {1,1,3,4}; |
| 197 | TensorShape outShape = {1,1,3,4}; |
| 198 | TensorInfo in(inShape, DataType::Signed64); |
| 199 | TensorInfo out(outShape, DataType::Signed64); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 200 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 201 | Pooling2dDescriptor desc; |
| 202 | TosaRefLayerSupport supportChecker; |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 203 | std::string reasonIfNotSupported; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 204 | auto supported = supportChecker.IsLayerSupported(LayerType::Pooling2d, |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 205 | {in, out}, |
| 206 | desc, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 207 | EmptyOptional(), |
| 208 | EmptyOptional(), |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 209 | reasonIfNotSupported); |
| 210 | |
| 211 | CHECK(!supported); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | TEST_CASE("IsLayerSupportedTosaReferenceAvgPooling2dUnsupported_InputOutputDatatypeDifferent") |
| 215 | { |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 216 | TensorShape inShape = {1,1,3,4}; |
| 217 | TensorShape outShape = {1,1,3,4}; |
| 218 | TensorInfo in(inShape, DataType::Float32); |
| 219 | TensorInfo out(outShape, DataType::Float16); |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 220 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 221 | Pooling2dDescriptor desc; |
| 222 | desc.m_PaddingMethod = PaddingMethod::IgnoreValue; |
| 223 | desc.m_PoolType = PoolingAlgorithm::Average; |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 224 | |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 225 | TosaRefLayerSupport supportChecker; |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 226 | std::string reasonIfNotSupported; |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 227 | auto supported = supportChecker.IsLayerSupported(LayerType::Pooling2d, |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 228 | {in, out}, |
| 229 | desc, |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 230 | EmptyOptional(), |
| 231 | EmptyOptional(), |
Cathal Corbett | bd18eab | 2022-11-15 12:56:16 +0000 | [diff] [blame] | 232 | reasonIfNotSupported); |
| 233 | |
| 234 | CHECK(!supported); |
Cathal Corbett | b30e655 | 2022-12-07 11:50:50 +0000 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | TEST_CASE("IsLayerSupportedTosaReferenceReshape") |
| 238 | { |
| 239 | TensorShape inShape = {3,4}; |
| 240 | TensorShape outShape = {12}; |
| 241 | TensorInfo in(inShape, DataType::Float32); |
| 242 | TensorInfo out(outShape, DataType::Float32); |
| 243 | |
| 244 | ReshapeDescriptor desc; |
| 245 | desc.m_TargetShape = {12}; |
| 246 | |
| 247 | TosaRefLayerSupport supportChecker; |
| 248 | std::string reasonIfNotSupported; |
| 249 | auto supported = supportChecker.IsLayerSupported(LayerType::Reshape, |
| 250 | {in, out}, |
| 251 | desc, |
| 252 | EmptyOptional(), |
| 253 | EmptyOptional(), |
| 254 | reasonIfNotSupported); |
| 255 | |
| 256 | CHECK(supported); |
| 257 | } |
| 258 | |
| 259 | TEST_CASE("IsLayerSupportedTosaReferenceReshapeUnsupported") |
| 260 | { |
| 261 | TensorShape inShape = {3,4}; |
| 262 | TensorShape outShape = {12}; |
| 263 | TensorInfo in(inShape, DataType::Signed64); |
| 264 | TensorInfo out(outShape, DataType::Signed64); |
| 265 | |
| 266 | ReshapeDescriptor desc; |
| 267 | desc.m_TargetShape = {12}; |
| 268 | |
| 269 | TosaRefLayerSupport supportChecker; |
| 270 | std::string reasonIfNotSupported; |
| 271 | auto supported = supportChecker.IsLayerSupported(LayerType::Reshape, |
| 272 | {in, out}, |
| 273 | desc, |
| 274 | EmptyOptional(), |
| 275 | EmptyOptional(), |
| 276 | reasonIfNotSupported); |
| 277 | |
| 278 | CHECK(!supported); |
Francis Murtagh | 9270d9e | 2022-08-12 13:54:17 +0100 | [diff] [blame] | 279 | } |
| 280 | |
Cathal Corbett | 3b9acd5 | 2022-12-09 12:17:27 +0000 | [diff] [blame] | 281 | TEST_CASE("IsLayerSupportedTosaReferenceSlice") |
| 282 | { |
| 283 | TensorShape inShape = {3,2,3}; |
| 284 | TensorShape outShape = {2,1,3}; |
| 285 | TensorInfo in(inShape, DataType::Float32); |
| 286 | TensorInfo out(outShape, DataType::Float32); |
| 287 | |
| 288 | SliceDescriptor descriptor; |
| 289 | descriptor.m_Begin = {1,0,0 }; |
| 290 | descriptor.m_Size = {2,1,3 }; |
| 291 | |
| 292 | TosaRefLayerSupport supportChecker; |
| 293 | std::string reasonIfNotSupported; |
| 294 | auto supported = supportChecker.IsLayerSupported(LayerType::Slice, |
| 295 | {in, out}, |
| 296 | descriptor, |
| 297 | EmptyOptional(), |
| 298 | EmptyOptional(), |
| 299 | reasonIfNotSupported); |
| 300 | |
| 301 | CHECK(supported); |
| 302 | } |
| 303 | |
| 304 | TEST_CASE("IsLayerSupportedTosaReferenceSliceUnsupported") |
| 305 | { |
| 306 | TensorShape inShape = {3,2,3}; |
| 307 | TensorShape outShape = {2,1,3}; |
| 308 | TensorInfo in(inShape, DataType::Signed64); |
| 309 | TensorInfo out(outShape, DataType::Signed64); |
| 310 | |
| 311 | SliceDescriptor descriptor; |
| 312 | descriptor.m_Begin = {1,0,0}; |
| 313 | descriptor.m_Size = {2,1,3}; |
| 314 | |
| 315 | TosaRefLayerSupport supportChecker; |
| 316 | std::string reasonIfNotSupported; |
| 317 | auto supported = supportChecker.IsLayerSupported(LayerType::Slice, |
| 318 | {in, out}, |
| 319 | descriptor, |
| 320 | EmptyOptional(), |
| 321 | EmptyOptional(), |
| 322 | reasonIfNotSupported); |
| 323 | |
| 324 | CHECK(!supported); |
Cathal Corbett | 3b9acd5 | 2022-12-09 12:17:27 +0000 | [diff] [blame] | 325 | } |
| 326 | |
Matthew Sloyan | fc9d5e7 | 2022-12-08 13:38:23 +0000 | [diff] [blame^] | 327 | TEST_CASE("IsLayerSupportedTosaReferenceTransposeConv2d") |
| 328 | { |
| 329 | TensorInfo inputInfo ({ 1, 3, 3, 1 }, DataType::Float32); |
| 330 | TensorInfo outputInfo({ 1, 5, 5, 1 }, DataType::Float32); |
| 331 | TensorInfo weightsInfo({ 1, 3, 3, 1 }, DataType::Float32); |
| 332 | TensorInfo biasesInfo ({ 1 }, DataType::Float32); |
| 333 | |
| 334 | TransposeConvolution2dDescriptor desc; |
| 335 | desc.m_StrideX = 1; |
| 336 | desc.m_StrideY = 1; |
| 337 | desc.m_BiasEnabled = true; |
| 338 | |
| 339 | TosaRefLayerSupport supportChecker; |
| 340 | std::string reasonIfNotSupported; |
| 341 | auto supported = supportChecker.IsLayerSupported(LayerType::TransposeConvolution2d, |
| 342 | {inputInfo, outputInfo, weightsInfo, biasesInfo}, |
| 343 | desc, |
| 344 | EmptyOptional(), |
| 345 | EmptyOptional(), |
| 346 | reasonIfNotSupported); |
| 347 | CHECK(supported); |
| 348 | } |
| 349 | |
| 350 | TEST_CASE("IsLayerSupportedTosaReferenceTransposeConv2dUnsupported") |
| 351 | { |
| 352 | // If inputs and weights are Fp32, output must match. |
| 353 | TensorInfo inputInfo ({ 1, 3, 3, 1 }, DataType::Float32); |
| 354 | TensorInfo outputInfo({ 1, 5, 5, 1 }, DataType::Float32); |
| 355 | TensorInfo weightsInfo({ 1, 3, 3, 1 }, DataType::Float32, 0.0f, 0, true); |
| 356 | TensorInfo biasesInfo ({ 1 }, DataType::Float32, 0.0f, 0, true); |
| 357 | |
| 358 | TransposeConvolution2dDescriptor desc; |
| 359 | desc.m_BiasEnabled = true; |
| 360 | |
| 361 | TosaRefLayerSupport supportChecker; |
| 362 | std::string reasonIfNotSupported; |
| 363 | auto supported = supportChecker.IsLayerSupported(LayerType::TransposeConvolution2d, |
| 364 | {inputInfo, outputInfo, weightsInfo, biasesInfo}, |
| 365 | desc, |
| 366 | EmptyOptional(), |
| 367 | EmptyOptional(), |
| 368 | reasonIfNotSupported); |
| 369 | CHECK(!supported); |
| 370 | } |
| 371 | |
Francis Murtagh | 9270d9e | 2022-08-12 13:54:17 +0100 | [diff] [blame] | 372 | } |