blob: fb4c84f07cb05808c9dd271d60fcaf07f3f50e2b [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
Teresa Charlince655882023-11-21 15:44:13 +0000355TEST_CASE("IsLayerSupportedTosaReferenceResize")
356{
357 TensorShape inShape = { 1, 720, 1280, 3 };
358 TensorShape outShape = { 1, 1080, 1920, 3 };
359 TensorInfo in(inShape, DataType::Float32);
360 TensorInfo out(outShape, DataType::Float32);
361
362 ResizeDescriptor descriptor;
363 descriptor.m_DataLayout = armnn::DataLayout::NHWC;
364 descriptor.m_TargetHeight = 1080;
365 descriptor.m_TargetWidth = 1920;
366
367 TosaRefLayerSupport supportChecker;
368 std::string reasonIfNotSupported;
369 auto supported = supportChecker.IsLayerSupported(LayerType::Resize,
370 {in, out},
371 descriptor,
372 EmptyOptional(),
373 EmptyOptional(),
374 reasonIfNotSupported);
375
376 CHECK(supported);
377}
378
Cathal Corbettb30e6552022-12-07 11:50:50 +0000379TEST_CASE("IsLayerSupportedTosaReferenceReshapeUnsupported")
380{
381 TensorShape inShape = {3,4};
382 TensorShape outShape = {12};
383 TensorInfo in(inShape, DataType::Signed64);
384 TensorInfo out(outShape, DataType::Signed64);
385
386 ReshapeDescriptor desc;
387 desc.m_TargetShape = {12};
388
389 TosaRefLayerSupport supportChecker;
390 std::string reasonIfNotSupported;
391 auto supported = supportChecker.IsLayerSupported(LayerType::Reshape,
392 {in, out},
393 desc,
394 EmptyOptional(),
395 EmptyOptional(),
396 reasonIfNotSupported);
397
398 CHECK(!supported);
Francis Murtagh9270d9e2022-08-12 13:54:17 +0100399}
400
David Monahand7fca092023-01-12 14:53:34 +0000401TEST_CASE("IsLayerSupportedTosaReferenceRsqrt")
402{
403 TensorShape shape0 = {2,2};
404 TensorShape outShape = {2,2};
405 TensorInfo in0(shape0, DataType::Float32);
406 TensorInfo out(outShape, DataType::Float32);
407
408 ElementwiseUnaryDescriptor desc(UnaryOperation::Rsqrt);
409 TosaRefLayerSupport supportChecker;
410 std::string reasonIfNotSupported;
411 auto supported = supportChecker.IsLayerSupported(LayerType::ElementwiseUnary,
412 {in0, out},
413 desc,
414 EmptyOptional(),
415 EmptyOptional(),
416 reasonIfNotSupported);
417
418 CHECK(supported);
419}
420
421TEST_CASE("IsLayerSupportedTosaReferenceRsqrtUnsupported")
422{
423 TensorShape shape0 = {1,1,3,4};
424 TensorShape outShape = {1,3,1,4};
425 TensorInfo in0(shape0, DataType::Signed64);
426 TensorInfo out(outShape, DataType::Signed64);
427
428 ElementwiseUnaryDescriptor desc(UnaryOperation::Rsqrt);
429 TosaRefLayerSupport supportChecker;
430 std::string reasonIfNotSupported;
431 auto supported = supportChecker.IsLayerSupported(LayerType::ElementwiseUnary,
432 {in0, out},
433 desc,
434 EmptyOptional(),
435 EmptyOptional(),
436 reasonIfNotSupported);
437
438 CHECK(!supported);
439}
440
Cathal Corbett3b9acd52022-12-09 12:17:27 +0000441TEST_CASE("IsLayerSupportedTosaReferenceSlice")
442{
443 TensorShape inShape = {3,2,3};
444 TensorShape outShape = {2,1,3};
445 TensorInfo in(inShape, DataType::Float32);
446 TensorInfo out(outShape, DataType::Float32);
447
448 SliceDescriptor descriptor;
449 descriptor.m_Begin = {1,0,0 };
450 descriptor.m_Size = {2,1,3 };
451
452 TosaRefLayerSupport supportChecker;
453 std::string reasonIfNotSupported;
454 auto supported = supportChecker.IsLayerSupported(LayerType::Slice,
455 {in, out},
456 descriptor,
457 EmptyOptional(),
458 EmptyOptional(),
459 reasonIfNotSupported);
460
461 CHECK(supported);
462}
463
464TEST_CASE("IsLayerSupportedTosaReferenceSliceUnsupported")
465{
466 TensorShape inShape = {3,2,3};
467 TensorShape outShape = {2,1,3};
468 TensorInfo in(inShape, DataType::Signed64);
469 TensorInfo out(outShape, DataType::Signed64);
470
471 SliceDescriptor descriptor;
472 descriptor.m_Begin = {1,0,0};
473 descriptor.m_Size = {2,1,3};
474
475 TosaRefLayerSupport supportChecker;
476 std::string reasonIfNotSupported;
477 auto supported = supportChecker.IsLayerSupported(LayerType::Slice,
478 {in, out},
479 descriptor,
480 EmptyOptional(),
481 EmptyOptional(),
482 reasonIfNotSupported);
483
484 CHECK(!supported);
Cathal Corbett3b9acd52022-12-09 12:17:27 +0000485}
486
Nikhil Raj9a339462022-12-05 11:24:35 +0000487TEST_CASE("IsLayerSupportedTosaReferenceSubtraction")
488{
489 TensorShape shape0 = {1,1,3,4};
490 TensorShape shape1 = {1,1,3,4};
491 TensorShape outShape = {1,1,3,4};
492 TensorInfo in0(shape0, armnn::DataType::Float32);
493 TensorInfo in1(shape1, armnn::DataType::Float32);
494 TensorInfo out(outShape, armnn::DataType::Float32);
495
496 BaseDescriptor desc;
497 TosaRefLayerSupport supportChecker;
498 std::string reasonIfNotSupported;
499 auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Subtraction,
500 {in0, in1, out},
501 desc,
502 armnn::EmptyOptional(),
503 armnn::EmptyOptional(),
504 reasonIfNotSupported);
505
506 CHECK(supported);
507}
508
509TEST_CASE("IsLayerSupportedTosaReferenceSubtractionUnsupported")
510{
511 TensorShape shape0 = {1,1,3,4};
512 TensorShape shape1 = {4};
513 TensorShape outShape = {1,1,3,4};
514 TensorInfo in0(shape0, armnn::DataType::Signed64);
515 TensorInfo in1(shape1, armnn::DataType::Signed64);
516 TensorInfo out(outShape, armnn::DataType::Signed64);
517
518 BaseDescriptor desc;
519 TosaRefLayerSupport supportChecker;
520 std::string reasonIfNotSupported;
521 auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Subtraction,
522 {in0, in1, out},
523 desc,
524 armnn::EmptyOptional(),
525 armnn::EmptyOptional(),
526 reasonIfNotSupported);
527
528 CHECK(!supported);
529}
530
Matthew Sloyanfc9d5e72022-12-08 13:38:23 +0000531TEST_CASE("IsLayerSupportedTosaReferenceTransposeConv2d")
532{
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);
536 TensorInfo biasesInfo ({ 1 }, DataType::Float32);
537
538 TransposeConvolution2dDescriptor desc;
539 desc.m_StrideX = 1;
540 desc.m_StrideY = 1;
541 desc.m_BiasEnabled = true;
542
543 TosaRefLayerSupport supportChecker;
544 std::string reasonIfNotSupported;
545 auto supported = supportChecker.IsLayerSupported(LayerType::TransposeConvolution2d,
546 {inputInfo, outputInfo, weightsInfo, biasesInfo},
547 desc,
548 EmptyOptional(),
549 EmptyOptional(),
550 reasonIfNotSupported);
551 CHECK(supported);
552}
553
554TEST_CASE("IsLayerSupportedTosaReferenceTransposeConv2dUnsupported")
555{
556 // If inputs and weights are Fp32, output must match.
557 TensorInfo inputInfo ({ 1, 3, 3, 1 }, DataType::Float32);
558 TensorInfo outputInfo({ 1, 5, 5, 1 }, DataType::Float32);
559 TensorInfo weightsInfo({ 1, 3, 3, 1 }, DataType::Float32, 0.0f, 0, true);
560 TensorInfo biasesInfo ({ 1 }, DataType::Float32, 0.0f, 0, true);
561
562 TransposeConvolution2dDescriptor desc;
563 desc.m_BiasEnabled = true;
564
565 TosaRefLayerSupport supportChecker;
566 std::string reasonIfNotSupported;
567 auto supported = supportChecker.IsLayerSupported(LayerType::TransposeConvolution2d,
568 {inputInfo, outputInfo, weightsInfo, biasesInfo},
569 desc,
570 EmptyOptional(),
571 EmptyOptional(),
572 reasonIfNotSupported);
573 CHECK(!supported);
574}
575
Cathal Corbett0bb096d2022-12-22 13:09:38 +0000576TEST_CASE("IsLayerSupportedTosaReferenceTranspose")
577{
578 TensorShape inShape = { 1, 1, 5, 3 };
579 TensorShape outShape = { 1, 5, 1, 3 };
580 TensorInfo in(inShape, DataType::Float32);
581 TensorInfo out(outShape, DataType::Float32);
582
583 TransposeDescriptor transposeDescriptor = TransposeDescriptor({ 0, 2, 1 ,3 });
584
585 TosaRefLayerSupport supportChecker;
586 std::string reasonIfNotSupported;
587 auto supported = supportChecker.IsLayerSupported(LayerType::Transpose,
588 {in, out},
589 transposeDescriptor,
590 EmptyOptional(),
591 EmptyOptional(),
592 reasonIfNotSupported);
593
594 CHECK(supported);
595}
596
597TEST_CASE("IsLayerSupportedTosaReferenceTransposeUnsupported")
598{
599 TensorShape inShape = { 1, 1, 5, 3 };
600 TensorShape outShape = { 1, 5, 1, 3 };
601 TensorInfo in(inShape, DataType::Signed64);
602 TensorInfo out(outShape, DataType::Signed64);
603
604 TransposeDescriptor transposeDescriptor = TransposeDescriptor({ 0, 2, 1 ,3 });
605
606 TosaRefLayerSupport supportChecker;
607 std::string reasonIfNotSupported;
608 auto supported = supportChecker.IsLayerSupported(LayerType::Transpose,
609 {in, out},
610 transposeDescriptor,
611 EmptyOptional(),
612 EmptyOptional(),
613 reasonIfNotSupported);
614
615 CHECK(!supported);
616}
617
Francis Murtagh9270d9e2022-08-12 13:54:17 +0100618}