blob: e32894f0b6c4f2efc022f795203036d92ffe9842 [file] [log] [blame]
Francis Murtagh9270d9e2022-08-12 13:54:17 +01001//
David Monahand7fca092023-01-12 14:53:34 +00002// Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved.
Francis Murtagh9270d9e2022-08-12 13:54:17 +01003// 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 Corbettb30e6552022-12-07 11:50:50 +000015using namespace armnn;
16
Francis Murtagh9270d9e2022-08-12 13:54:17 +010017TEST_SUITE("TosaRefLayerSupported")
18{
19
20TEST_CASE("IsLayerSupportedTosaReferenceAddition")
21{
Cathal Corbettb30e6552022-12-07 11:50:50 +000022 TensorShape shape0 = {1,1,3,4};
Matthew Sloyan67fd5262022-12-07 19:28:18 +000023 TensorShape shape1 = {1,1,3,4};
Cathal Corbettb30e6552022-12-07 11:50:50 +000024 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 Murtagh9270d9e2022-08-12 13:54:17 +010028
Cathal Corbettb30e6552022-12-07 11:50:50 +000029 BaseDescriptor desc;
30 TosaRefLayerSupport supportChecker;
Francis Murtagh9270d9e2022-08-12 13:54:17 +010031 std::string reasonIfNotSupported;
Cathal Corbettb30e6552022-12-07 11:50:50 +000032 auto supported = supportChecker.IsLayerSupported(LayerType::Addition,
Francis Murtagh9270d9e2022-08-12 13:54:17 +010033 {in0, in1, out},
34 desc,
Cathal Corbettb30e6552022-12-07 11:50:50 +000035 EmptyOptional(),
36 EmptyOptional(),
Francis Murtagh9270d9e2022-08-12 13:54:17 +010037 reasonIfNotSupported);
38
39 CHECK(supported);
40}
41
42TEST_CASE("IsLayerSupportedTosaReferenceAdditionUnsupported")
43{
Cathal Corbettb30e6552022-12-07 11:50:50 +000044 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 Murtagh9270d9e2022-08-12 13:54:17 +010050
Cathal Corbettb30e6552022-12-07 11:50:50 +000051 BaseDescriptor desc;
52 TosaRefLayerSupport supportChecker;
Francis Murtagh9270d9e2022-08-12 13:54:17 +010053 std::string reasonIfNotSupported;
Cathal Corbettb30e6552022-12-07 11:50:50 +000054 auto supported = supportChecker.IsLayerSupported(LayerType::Addition,
Francis Murtagh9270d9e2022-08-12 13:54:17 +010055 {in0, in1, out},
56 desc,
Cathal Corbettb30e6552022-12-07 11:50:50 +000057 EmptyOptional(),
58 EmptyOptional(),
Francis Murtagh9270d9e2022-08-12 13:54:17 +010059 reasonIfNotSupported);
60
61 CHECK(!supported);
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +000062}
63
Kevin May5b58e312022-12-15 10:15:21 +000064TEST_CASE("IsLayerSupportedTosaReferenceConcat")
65{
66 TensorShape input0Shape = { 2, 3, 2, 2 };
67 TensorShape input1Shape = { 2, 3, 2, 2 };
68 TensorShape outputShape = { 2, 6, 2, 2 };
69 TensorInfo input0Info(input0Shape, DataType::Float32);
70 TensorInfo input1Info(input1Shape, DataType::Float32);
71 TensorInfo outputInfo(outputShape, DataType::Float32);
72
73 OriginsDescriptor descriptor;
74 std::vector<TensorShape> shapes = {input0Shape, input1Shape} ;
75 unsigned int concatAxis = 1;
76 descriptor = CreateDescriptorForConcatenation(shapes.begin(), shapes.end(), concatAxis);
77
78 TosaRefLayerSupport supportChecker;
79 std::string reasonIfNotSupported;
80 auto supported = supportChecker.IsLayerSupported(LayerType::Concat,
81 {input0Info, input1Info, outputInfo},
82 descriptor,
83 EmptyOptional(),
84 EmptyOptional(),
85 reasonIfNotSupported);
86
87 CHECK(supported);
88}
89
90TEST_CASE("IsLayerSupportedTosaReferenceConcatUnsupported")
91{
92 TensorShape input0Shape = { 2, 3, 2, 2 };
93 TensorShape input1Shape = { 2, 3, 2, 2 };
94 TensorShape outputShape = { 2, 6, 2, 2 };
95 TensorInfo input0Info(input0Shape, armnn::DataType::QAsymmU8);
96 TensorInfo input1Info(input1Shape, armnn::DataType::QAsymmU8);
97 TensorInfo outputInfo(outputShape, armnn::DataType::QAsymmU8);
98
99 OriginsDescriptor descriptor;
100 std::vector<armnn::TensorShape> shapes = {input0Shape, input1Shape} ;
101 unsigned int concatAxis = 1;
102 descriptor = armnn::CreateDescriptorForConcatenation(shapes.begin(), shapes.end(), concatAxis);
103
104 TosaRefLayerSupport supportChecker;
105 std::string reasonIfNotSupported;
106 auto supported = supportChecker.IsLayerSupported(LayerType::Concat,
107 {input0Info, input1Info, outputInfo},
108 descriptor,
109 EmptyOptional(),
110 EmptyOptional(),
111 reasonIfNotSupported);
112
113 CHECK(!supported);
114}
115
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000116TEST_CASE("IsLayerSupportedTosaReferenceConstant")
117{
Cathal Corbettb30e6552022-12-07 11:50:50 +0000118 TensorInfo outputInfo({1,1,3,4}, DataType::Float32);
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000119
Cathal Corbettb30e6552022-12-07 11:50:50 +0000120 TosaRefLayerSupport supportChecker;
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000121 std::string reasonIfNotSupported;
Cathal Corbettb30e6552022-12-07 11:50:50 +0000122 auto supported = supportChecker.IsLayerSupported(LayerType::Constant,
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000123 {outputInfo},
Cathal Corbettb30e6552022-12-07 11:50:50 +0000124 BaseDescriptor(),
125 EmptyOptional(),
126 EmptyOptional(),
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000127 reasonIfNotSupported);
128
129 CHECK(supported);
130}
131
132TEST_CASE("IsLayerSupportedTosaReferenceConstantUnsupported")
133{
Cathal Corbettb30e6552022-12-07 11:50:50 +0000134 TensorInfo outputInfo({1,1,3,4}, DataType::Signed64);
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000135
Cathal Corbettb30e6552022-12-07 11:50:50 +0000136 TosaRefLayerSupport supportChecker;
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000137 std::string reasonIfNotSupported;
Cathal Corbettb30e6552022-12-07 11:50:50 +0000138 auto supported = supportChecker.IsLayerSupported(LayerType::Constant,
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000139 {outputInfo},
Cathal Corbettb30e6552022-12-07 11:50:50 +0000140 BaseDescriptor(),
141 EmptyOptional(),
142 EmptyOptional(),
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000143 reasonIfNotSupported);
144
145 CHECK(!supported);
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000146}
147
148TEST_CASE("IsLayerSupportedTosaReferenceConv2d")
149{
Cathal Corbettb30e6552022-12-07 11:50:50 +0000150 TensorInfo inputInfo ({ 1, 5, 5, 1 }, DataType::Float32);
151 TensorInfo outputInfo({ 1, 3, 3, 1 }, DataType::Float32);
152 TensorInfo weightsInfo({ 1, 3, 3, 1 }, DataType::Float32);
153 TensorInfo biasesInfo ({ 1 }, DataType::Float32);
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000154
Cathal Corbettb30e6552022-12-07 11:50:50 +0000155 Convolution2dDescriptor desc;
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000156 desc.m_BiasEnabled = true;
157
Cathal Corbettb30e6552022-12-07 11:50:50 +0000158 TosaRefLayerSupport supportChecker;
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000159 std::string reasonIfNotSupported;
Matthew Sloyanfc9d5e72022-12-08 13:38:23 +0000160 auto supported = supportChecker.IsLayerSupported(LayerType::Convolution2d,
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000161 {inputInfo, outputInfo, weightsInfo, biasesInfo},
162 desc,
Cathal Corbettb30e6552022-12-07 11:50:50 +0000163 EmptyOptional(),
164 EmptyOptional(),
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000165 reasonIfNotSupported);
166
167 CHECK(supported);
168}
169
170TEST_CASE("IsLayerSupportedTosaReferenceConv2dUnsupported")
171{
172 // If inputs and weights are Fp32, output must match.
Cathal Corbettb30e6552022-12-07 11:50:50 +0000173 TensorInfo inputInfo ({ 1, 5, 5, 1 }, DataType::Float32);
174 TensorInfo outputInfo({ 1, 3, 3, 1 }, DataType::Signed64);
175 TensorInfo weightsInfo({ 1, 3, 3, 1 }, DataType::Float32, 0.0f, 0, true);
176 TensorInfo biasesInfo ({ 1 }, DataType::Float32, 0.0f, 0, true);
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000177
Cathal Corbettb30e6552022-12-07 11:50:50 +0000178 Convolution2dDescriptor desc;
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000179 desc.m_BiasEnabled = true;
180
Cathal Corbettb30e6552022-12-07 11:50:50 +0000181 TosaRefLayerSupport supportChecker;
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000182 std::string reasonIfNotSupported;
Matthew Sloyanfc9d5e72022-12-08 13:38:23 +0000183 auto supported = supportChecker.IsLayerSupported(LayerType::Convolution2d,
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000184 {inputInfo, outputInfo, weightsInfo, biasesInfo},
185 desc,
Cathal Corbettb30e6552022-12-07 11:50:50 +0000186 EmptyOptional(),
187 EmptyOptional(),
Matthew Sloyanc5fe6e72022-11-25 16:10:00 +0000188 reasonIfNotSupported);
189
190 CHECK(!supported);
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000191}
192
Nikhil Raj9a339462022-12-05 11:24:35 +0000193TEST_CASE("IsLayerSupportedTosaReferenceMultiplication")
194{
195 TensorShape shape0 = {1,1,3,4};
196 TensorShape shape1 = {1,1,3,4};
197 TensorShape outShape = {1,1,3,4};
198 TensorInfo in0(shape0, armnn::DataType::Float32);
199 TensorInfo in1(shape1, armnn::DataType::Float32);
200 TensorInfo out(outShape, armnn::DataType::Float32);
201
202 BaseDescriptor desc;
203 TosaRefLayerSupport supportChecker;
204 std::string reasonIfNotSupported;
205 auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Multiplication,
206 {in0, in1, out},
207 desc,
208 armnn::EmptyOptional(),
209 armnn::EmptyOptional(),
210 reasonIfNotSupported);
211
212 CHECK(supported);
213}
214
215TEST_CASE("IsLayerSupportedTosaReferenceMultiplicationUnsupported")
216{
217 TensorShape shape0 = {1,1,3,4};
218 TensorShape shape1 = {1,2,3,4};
219 TensorShape outShape = {1,1,3,4};
220 TensorInfo in0(shape0, armnn::DataType::Signed64);
221 TensorInfo in1(shape1, armnn::DataType::Signed64);
222 TensorInfo out(outShape, armnn::DataType::Signed64);
223
224 BaseDescriptor desc;
225 TosaRefLayerSupport supportChecker;
226 std::string reasonIfNotSupported;
227 auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Multiplication,
228 {in0, in1, out},
229 desc,
230 armnn::EmptyOptional(),
231 armnn::EmptyOptional(),
232 reasonIfNotSupported);
233
234 CHECK(!supported);
235}
236
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000237TEST_CASE("IsLayerSupportedTosaReferenceMaxPooling2d")
238{
Cathal Corbettb30e6552022-12-07 11:50:50 +0000239 TensorShape inShape = {1,1,3,4};
240 TensorShape outShape = {1,1,3,4};
241 TensorInfo in(inShape, DataType::Float32);
242 TensorInfo out(outShape, DataType::Float32);
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000243
Cathal Corbettb30e6552022-12-07 11:50:50 +0000244 Pooling2dDescriptor desc;
Matthew Sloyan67fd5262022-12-07 19:28:18 +0000245 desc.m_PoolHeight = 1;
246 desc.m_PoolWidth = 1;
247 desc.m_StrideX = 1;
248 desc.m_StrideY = 1;
Matthew Sloyanfc9d5e72022-12-08 13:38:23 +0000249 desc.m_PoolType = PoolingAlgorithm::Max;
Matthew Sloyan67fd5262022-12-07 19:28:18 +0000250
Cathal Corbettb30e6552022-12-07 11:50:50 +0000251 TosaRefLayerSupport supportChecker;
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000252 std::string reasonIfNotSupported;
Cathal Corbettb30e6552022-12-07 11:50:50 +0000253 auto supported = supportChecker.IsLayerSupported(LayerType::Pooling2d,
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000254 {in, out},
255 desc,
Cathal Corbettb30e6552022-12-07 11:50:50 +0000256 EmptyOptional(),
257 EmptyOptional(),
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000258 reasonIfNotSupported);
259
260 CHECK(supported);
261}
262
263TEST_CASE("IsLayerSupportedTosaReferenceAvgPooling2d_IgnoreValue")
264{
Cathal Corbettb30e6552022-12-07 11:50:50 +0000265 TensorShape inShape = {1,1,3,4};
266 TensorShape outShape = {1,1,3,4};
267 TensorInfo in(inShape, DataType::Float32);
268 TensorInfo out(outShape, DataType::Float32);
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000269
Cathal Corbettb30e6552022-12-07 11:50:50 +0000270 Pooling2dDescriptor desc;
Matthew Sloyan67fd5262022-12-07 19:28:18 +0000271 desc.m_PoolHeight = 1;
272 desc.m_PoolWidth = 1;
273 desc.m_StrideX = 1;
274 desc.m_StrideY = 1;
Cathal Corbettb30e6552022-12-07 11:50:50 +0000275 desc.m_PaddingMethod = PaddingMethod::IgnoreValue;
276 desc.m_PoolType = PoolingAlgorithm::Average;
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000277
Cathal Corbettb30e6552022-12-07 11:50:50 +0000278 TosaRefLayerSupport supportChecker;
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000279 std::string reasonIfNotSupported;
Cathal Corbettb30e6552022-12-07 11:50:50 +0000280 auto supported = supportChecker.IsLayerSupported(LayerType::Pooling2d,
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000281 {in, out},
282 desc,
Cathal Corbettb30e6552022-12-07 11:50:50 +0000283 EmptyOptional(),
284 EmptyOptional(),
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000285 reasonIfNotSupported);
286
287 CHECK(supported);
288}
289
290TEST_CASE("IsLayerSupportedTosaReferenceMaxPooling2dUnsupported")
291{
Cathal Corbettb30e6552022-12-07 11:50:50 +0000292 TensorShape inShape = {1,1,3,4};
293 TensorShape outShape = {1,1,3,4};
294 TensorInfo in(inShape, DataType::Signed64);
295 TensorInfo out(outShape, DataType::Signed64);
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000296
Cathal Corbettb30e6552022-12-07 11:50:50 +0000297 Pooling2dDescriptor desc;
298 TosaRefLayerSupport supportChecker;
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000299 std::string reasonIfNotSupported;
Cathal Corbettb30e6552022-12-07 11:50:50 +0000300 auto supported = supportChecker.IsLayerSupported(LayerType::Pooling2d,
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000301 {in, out},
302 desc,
Cathal Corbettb30e6552022-12-07 11:50:50 +0000303 EmptyOptional(),
304 EmptyOptional(),
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000305 reasonIfNotSupported);
306
307 CHECK(!supported);
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000308}
309
310TEST_CASE("IsLayerSupportedTosaReferenceAvgPooling2dUnsupported_InputOutputDatatypeDifferent")
311{
Cathal Corbettb30e6552022-12-07 11:50:50 +0000312 TensorShape inShape = {1,1,3,4};
313 TensorShape outShape = {1,1,3,4};
314 TensorInfo in(inShape, DataType::Float32);
315 TensorInfo out(outShape, DataType::Float16);
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000316
Cathal Corbettb30e6552022-12-07 11:50:50 +0000317 Pooling2dDescriptor desc;
318 desc.m_PaddingMethod = PaddingMethod::IgnoreValue;
319 desc.m_PoolType = PoolingAlgorithm::Average;
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000320
Cathal Corbettb30e6552022-12-07 11:50:50 +0000321 TosaRefLayerSupport supportChecker;
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000322 std::string reasonIfNotSupported;
Cathal Corbettb30e6552022-12-07 11:50:50 +0000323 auto supported = supportChecker.IsLayerSupported(LayerType::Pooling2d,
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000324 {in, out},
325 desc,
Cathal Corbettb30e6552022-12-07 11:50:50 +0000326 EmptyOptional(),
327 EmptyOptional(),
Cathal Corbettbd18eab2022-11-15 12:56:16 +0000328 reasonIfNotSupported);
329
330 CHECK(!supported);
Cathal Corbettb30e6552022-12-07 11:50:50 +0000331}
332
333TEST_CASE("IsLayerSupportedTosaReferenceReshape")
334{
335 TensorShape inShape = {3,4};
336 TensorShape outShape = {12};
337 TensorInfo in(inShape, DataType::Float32);
338 TensorInfo out(outShape, DataType::Float32);
339
340 ReshapeDescriptor desc;
341 desc.m_TargetShape = {12};
342
343 TosaRefLayerSupport supportChecker;
344 std::string reasonIfNotSupported;
345 auto supported = supportChecker.IsLayerSupported(LayerType::Reshape,
346 {in, out},
347 desc,
348 EmptyOptional(),
349 EmptyOptional(),
350 reasonIfNotSupported);
351
352 CHECK(supported);
353}
354
355TEST_CASE("IsLayerSupportedTosaReferenceReshapeUnsupported")
356{
357 TensorShape inShape = {3,4};
358 TensorShape outShape = {12};
359 TensorInfo in(inShape, DataType::Signed64);
360 TensorInfo out(outShape, DataType::Signed64);
361
362 ReshapeDescriptor desc;
363 desc.m_TargetShape = {12};
364
365 TosaRefLayerSupport supportChecker;
366 std::string reasonIfNotSupported;
367 auto supported = supportChecker.IsLayerSupported(LayerType::Reshape,
368 {in, out},
369 desc,
370 EmptyOptional(),
371 EmptyOptional(),
372 reasonIfNotSupported);
373
374 CHECK(!supported);
Francis Murtagh9270d9e2022-08-12 13:54:17 +0100375}
376
David Monahand7fca092023-01-12 14:53:34 +0000377TEST_CASE("IsLayerSupportedTosaReferenceRsqrt")
378{
379 TensorShape shape0 = {2,2};
380 TensorShape outShape = {2,2};
381 TensorInfo in0(shape0, DataType::Float32);
382 TensorInfo out(outShape, DataType::Float32);
383
384 ElementwiseUnaryDescriptor desc(UnaryOperation::Rsqrt);
385 TosaRefLayerSupport supportChecker;
386 std::string reasonIfNotSupported;
387 auto supported = supportChecker.IsLayerSupported(LayerType::ElementwiseUnary,
388 {in0, out},
389 desc,
390 EmptyOptional(),
391 EmptyOptional(),
392 reasonIfNotSupported);
393
394 CHECK(supported);
395}
396
397TEST_CASE("IsLayerSupportedTosaReferenceRsqrtUnsupported")
398{
399 TensorShape shape0 = {1,1,3,4};
400 TensorShape outShape = {1,3,1,4};
401 TensorInfo in0(shape0, DataType::Signed64);
402 TensorInfo out(outShape, DataType::Signed64);
403
404 ElementwiseUnaryDescriptor desc(UnaryOperation::Rsqrt);
405 TosaRefLayerSupport supportChecker;
406 std::string reasonIfNotSupported;
407 auto supported = supportChecker.IsLayerSupported(LayerType::ElementwiseUnary,
408 {in0, out},
409 desc,
410 EmptyOptional(),
411 EmptyOptional(),
412 reasonIfNotSupported);
413
414 CHECK(!supported);
415}
416
Cathal Corbett3b9acd52022-12-09 12:17:27 +0000417TEST_CASE("IsLayerSupportedTosaReferenceSlice")
418{
419 TensorShape inShape = {3,2,3};
420 TensorShape outShape = {2,1,3};
421 TensorInfo in(inShape, DataType::Float32);
422 TensorInfo out(outShape, DataType::Float32);
423
424 SliceDescriptor descriptor;
425 descriptor.m_Begin = {1,0,0 };
426 descriptor.m_Size = {2,1,3 };
427
428 TosaRefLayerSupport supportChecker;
429 std::string reasonIfNotSupported;
430 auto supported = supportChecker.IsLayerSupported(LayerType::Slice,
431 {in, out},
432 descriptor,
433 EmptyOptional(),
434 EmptyOptional(),
435 reasonIfNotSupported);
436
437 CHECK(supported);
438}
439
440TEST_CASE("IsLayerSupportedTosaReferenceSliceUnsupported")
441{
442 TensorShape inShape = {3,2,3};
443 TensorShape outShape = {2,1,3};
444 TensorInfo in(inShape, DataType::Signed64);
445 TensorInfo out(outShape, DataType::Signed64);
446
447 SliceDescriptor descriptor;
448 descriptor.m_Begin = {1,0,0};
449 descriptor.m_Size = {2,1,3};
450
451 TosaRefLayerSupport supportChecker;
452 std::string reasonIfNotSupported;
453 auto supported = supportChecker.IsLayerSupported(LayerType::Slice,
454 {in, out},
455 descriptor,
456 EmptyOptional(),
457 EmptyOptional(),
458 reasonIfNotSupported);
459
460 CHECK(!supported);
Cathal Corbett3b9acd52022-12-09 12:17:27 +0000461}
462
Nikhil Raj9a339462022-12-05 11:24:35 +0000463TEST_CASE("IsLayerSupportedTosaReferenceSubtraction")
464{
465 TensorShape shape0 = {1,1,3,4};
466 TensorShape shape1 = {1,1,3,4};
467 TensorShape outShape = {1,1,3,4};
468 TensorInfo in0(shape0, armnn::DataType::Float32);
469 TensorInfo in1(shape1, armnn::DataType::Float32);
470 TensorInfo out(outShape, armnn::DataType::Float32);
471
472 BaseDescriptor desc;
473 TosaRefLayerSupport supportChecker;
474 std::string reasonIfNotSupported;
475 auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Subtraction,
476 {in0, in1, out},
477 desc,
478 armnn::EmptyOptional(),
479 armnn::EmptyOptional(),
480 reasonIfNotSupported);
481
482 CHECK(supported);
483}
484
485TEST_CASE("IsLayerSupportedTosaReferenceSubtractionUnsupported")
486{
487 TensorShape shape0 = {1,1,3,4};
488 TensorShape shape1 = {4};
489 TensorShape outShape = {1,1,3,4};
490 TensorInfo in0(shape0, armnn::DataType::Signed64);
491 TensorInfo in1(shape1, armnn::DataType::Signed64);
492 TensorInfo out(outShape, armnn::DataType::Signed64);
493
494 BaseDescriptor desc;
495 TosaRefLayerSupport supportChecker;
496 std::string reasonIfNotSupported;
497 auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Subtraction,
498 {in0, in1, out},
499 desc,
500 armnn::EmptyOptional(),
501 armnn::EmptyOptional(),
502 reasonIfNotSupported);
503
504 CHECK(!supported);
505}
506
Matthew Sloyanfc9d5e72022-12-08 13:38:23 +0000507TEST_CASE("IsLayerSupportedTosaReferenceTransposeConv2d")
508{
509 TensorInfo inputInfo ({ 1, 3, 3, 1 }, DataType::Float32);
510 TensorInfo outputInfo({ 1, 5, 5, 1 }, DataType::Float32);
511 TensorInfo weightsInfo({ 1, 3, 3, 1 }, DataType::Float32);
512 TensorInfo biasesInfo ({ 1 }, DataType::Float32);
513
514 TransposeConvolution2dDescriptor desc;
515 desc.m_StrideX = 1;
516 desc.m_StrideY = 1;
517 desc.m_BiasEnabled = true;
518
519 TosaRefLayerSupport supportChecker;
520 std::string reasonIfNotSupported;
521 auto supported = supportChecker.IsLayerSupported(LayerType::TransposeConvolution2d,
522 {inputInfo, outputInfo, weightsInfo, biasesInfo},
523 desc,
524 EmptyOptional(),
525 EmptyOptional(),
526 reasonIfNotSupported);
527 CHECK(supported);
528}
529
530TEST_CASE("IsLayerSupportedTosaReferenceTransposeConv2dUnsupported")
531{
532 // If inputs and weights are Fp32, output must match.
533 TensorInfo inputInfo ({ 1, 3, 3, 1 }, DataType::Float32);
534 TensorInfo outputInfo({ 1, 5, 5, 1 }, DataType::Float32);
535 TensorInfo weightsInfo({ 1, 3, 3, 1 }, DataType::Float32, 0.0f, 0, true);
536 TensorInfo biasesInfo ({ 1 }, DataType::Float32, 0.0f, 0, true);
537
538 TransposeConvolution2dDescriptor desc;
539 desc.m_BiasEnabled = true;
540
541 TosaRefLayerSupport supportChecker;
542 std::string reasonIfNotSupported;
543 auto supported = supportChecker.IsLayerSupported(LayerType::TransposeConvolution2d,
544 {inputInfo, outputInfo, weightsInfo, biasesInfo},
545 desc,
546 EmptyOptional(),
547 EmptyOptional(),
548 reasonIfNotSupported);
549 CHECK(!supported);
550}
551
Cathal Corbett0bb096d2022-12-22 13:09:38 +0000552TEST_CASE("IsLayerSupportedTosaReferenceTranspose")
553{
554 TensorShape inShape = { 1, 1, 5, 3 };
555 TensorShape outShape = { 1, 5, 1, 3 };
556 TensorInfo in(inShape, DataType::Float32);
557 TensorInfo out(outShape, DataType::Float32);
558
559 TransposeDescriptor transposeDescriptor = TransposeDescriptor({ 0, 2, 1 ,3 });
560
561 TosaRefLayerSupport supportChecker;
562 std::string reasonIfNotSupported;
563 auto supported = supportChecker.IsLayerSupported(LayerType::Transpose,
564 {in, out},
565 transposeDescriptor,
566 EmptyOptional(),
567 EmptyOptional(),
568 reasonIfNotSupported);
569
570 CHECK(supported);
571}
572
573TEST_CASE("IsLayerSupportedTosaReferenceTransposeUnsupported")
574{
575 TensorShape inShape = { 1, 1, 5, 3 };
576 TensorShape outShape = { 1, 5, 1, 3 };
577 TensorInfo in(inShape, DataType::Signed64);
578 TensorInfo out(outShape, DataType::Signed64);
579
580 TransposeDescriptor transposeDescriptor = TransposeDescriptor({ 0, 2, 1 ,3 });
581
582 TosaRefLayerSupport supportChecker;
583 std::string reasonIfNotSupported;
584 auto supported = supportChecker.IsLayerSupported(LayerType::Transpose,
585 {in, out},
586 transposeDescriptor,
587 EmptyOptional(),
588 EmptyOptional(),
589 reasonIfNotSupported);
590
591 CHECK(!supported);
592}
593
Francis Murtagh9270d9e2022-08-12 13:54:17 +0100594}