blob: 66dfbe8dff486c9ae44881f9c215dcf6207895cc [file] [log] [blame]
Francis Murtagh9270d9e2022-08-12 13:54:17 +01001//
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 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
Cathal Corbett3b9acd52022-12-09 12:17:27 +0000377TEST_CASE("IsLayerSupportedTosaReferenceSlice")
378{
379 TensorShape inShape = {3,2,3};
380 TensorShape outShape = {2,1,3};
381 TensorInfo in(inShape, DataType::Float32);
382 TensorInfo out(outShape, DataType::Float32);
383
384 SliceDescriptor descriptor;
385 descriptor.m_Begin = {1,0,0 };
386 descriptor.m_Size = {2,1,3 };
387
388 TosaRefLayerSupport supportChecker;
389 std::string reasonIfNotSupported;
390 auto supported = supportChecker.IsLayerSupported(LayerType::Slice,
391 {in, out},
392 descriptor,
393 EmptyOptional(),
394 EmptyOptional(),
395 reasonIfNotSupported);
396
397 CHECK(supported);
398}
399
400TEST_CASE("IsLayerSupportedTosaReferenceSliceUnsupported")
401{
402 TensorShape inShape = {3,2,3};
403 TensorShape outShape = {2,1,3};
404 TensorInfo in(inShape, DataType::Signed64);
405 TensorInfo out(outShape, DataType::Signed64);
406
407 SliceDescriptor descriptor;
408 descriptor.m_Begin = {1,0,0};
409 descriptor.m_Size = {2,1,3};
410
411 TosaRefLayerSupport supportChecker;
412 std::string reasonIfNotSupported;
413 auto supported = supportChecker.IsLayerSupported(LayerType::Slice,
414 {in, out},
415 descriptor,
416 EmptyOptional(),
417 EmptyOptional(),
418 reasonIfNotSupported);
419
420 CHECK(!supported);
Cathal Corbett3b9acd52022-12-09 12:17:27 +0000421}
422
Nikhil Raj9a339462022-12-05 11:24:35 +0000423TEST_CASE("IsLayerSupportedTosaReferenceSubtraction")
424{
425 TensorShape shape0 = {1,1,3,4};
426 TensorShape shape1 = {1,1,3,4};
427 TensorShape outShape = {1,1,3,4};
428 TensorInfo in0(shape0, armnn::DataType::Float32);
429 TensorInfo in1(shape1, armnn::DataType::Float32);
430 TensorInfo out(outShape, armnn::DataType::Float32);
431
432 BaseDescriptor desc;
433 TosaRefLayerSupport supportChecker;
434 std::string reasonIfNotSupported;
435 auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Subtraction,
436 {in0, in1, out},
437 desc,
438 armnn::EmptyOptional(),
439 armnn::EmptyOptional(),
440 reasonIfNotSupported);
441
442 CHECK(supported);
443}
444
445TEST_CASE("IsLayerSupportedTosaReferenceSubtractionUnsupported")
446{
447 TensorShape shape0 = {1,1,3,4};
448 TensorShape shape1 = {4};
449 TensorShape outShape = {1,1,3,4};
450 TensorInfo in0(shape0, armnn::DataType::Signed64);
451 TensorInfo in1(shape1, armnn::DataType::Signed64);
452 TensorInfo out(outShape, armnn::DataType::Signed64);
453
454 BaseDescriptor desc;
455 TosaRefLayerSupport supportChecker;
456 std::string reasonIfNotSupported;
457 auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Subtraction,
458 {in0, in1, out},
459 desc,
460 armnn::EmptyOptional(),
461 armnn::EmptyOptional(),
462 reasonIfNotSupported);
463
464 CHECK(!supported);
465}
466
Matthew Sloyanfc9d5e72022-12-08 13:38:23 +0000467TEST_CASE("IsLayerSupportedTosaReferenceTransposeConv2d")
468{
469 TensorInfo inputInfo ({ 1, 3, 3, 1 }, DataType::Float32);
470 TensorInfo outputInfo({ 1, 5, 5, 1 }, DataType::Float32);
471 TensorInfo weightsInfo({ 1, 3, 3, 1 }, DataType::Float32);
472 TensorInfo biasesInfo ({ 1 }, DataType::Float32);
473
474 TransposeConvolution2dDescriptor desc;
475 desc.m_StrideX = 1;
476 desc.m_StrideY = 1;
477 desc.m_BiasEnabled = true;
478
479 TosaRefLayerSupport supportChecker;
480 std::string reasonIfNotSupported;
481 auto supported = supportChecker.IsLayerSupported(LayerType::TransposeConvolution2d,
482 {inputInfo, outputInfo, weightsInfo, biasesInfo},
483 desc,
484 EmptyOptional(),
485 EmptyOptional(),
486 reasonIfNotSupported);
487 CHECK(supported);
488}
489
490TEST_CASE("IsLayerSupportedTosaReferenceTransposeConv2dUnsupported")
491{
492 // If inputs and weights are Fp32, output must match.
493 TensorInfo inputInfo ({ 1, 3, 3, 1 }, DataType::Float32);
494 TensorInfo outputInfo({ 1, 5, 5, 1 }, DataType::Float32);
495 TensorInfo weightsInfo({ 1, 3, 3, 1 }, DataType::Float32, 0.0f, 0, true);
496 TensorInfo biasesInfo ({ 1 }, DataType::Float32, 0.0f, 0, true);
497
498 TransposeConvolution2dDescriptor desc;
499 desc.m_BiasEnabled = true;
500
501 TosaRefLayerSupport supportChecker;
502 std::string reasonIfNotSupported;
503 auto supported = supportChecker.IsLayerSupported(LayerType::TransposeConvolution2d,
504 {inputInfo, outputInfo, weightsInfo, biasesInfo},
505 desc,
506 EmptyOptional(),
507 EmptyOptional(),
508 reasonIfNotSupported);
509 CHECK(!supported);
510}
511
Cathal Corbett0bb096d2022-12-22 13:09:38 +0000512TEST_CASE("IsLayerSupportedTosaReferenceTranspose")
513{
514 TensorShape inShape = { 1, 1, 5, 3 };
515 TensorShape outShape = { 1, 5, 1, 3 };
516 TensorInfo in(inShape, DataType::Float32);
517 TensorInfo out(outShape, DataType::Float32);
518
519 TransposeDescriptor transposeDescriptor = TransposeDescriptor({ 0, 2, 1 ,3 });
520
521 TosaRefLayerSupport supportChecker;
522 std::string reasonIfNotSupported;
523 auto supported = supportChecker.IsLayerSupported(LayerType::Transpose,
524 {in, out},
525 transposeDescriptor,
526 EmptyOptional(),
527 EmptyOptional(),
528 reasonIfNotSupported);
529
530 CHECK(supported);
531}
532
533TEST_CASE("IsLayerSupportedTosaReferenceTransposeUnsupported")
534{
535 TensorShape inShape = { 1, 1, 5, 3 };
536 TensorShape outShape = { 1, 5, 1, 3 };
537 TensorInfo in(inShape, DataType::Signed64);
538 TensorInfo out(outShape, DataType::Signed64);
539
540 TransposeDescriptor transposeDescriptor = TransposeDescriptor({ 0, 2, 1 ,3 });
541
542 TosaRefLayerSupport supportChecker;
543 std::string reasonIfNotSupported;
544 auto supported = supportChecker.IsLayerSupported(LayerType::Transpose,
545 {in, out},
546 transposeDescriptor,
547 EmptyOptional(),
548 EmptyOptional(),
549 reasonIfNotSupported);
550
551 CHECK(!supported);
552}
553
Francis Murtagh9270d9e2022-08-12 13:54:17 +0100554}