blob: ff31d277748be7453687e2dfa89ac0b5cf784e77 [file] [log] [blame]
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "MinimumTestImpl.hpp"
7
8#include "ElementwiseTestImpl.hpp"
9
10template<>
11std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::MinimumQueueDescriptor>(
12 const armnn::IWorkloadFactory& workloadFactory,
13 const armnn::WorkloadInfo& info,
14 const armnn::MinimumQueueDescriptor& descriptor)
15{
Teresa Charlin611c7fb2022-01-07 09:47:29 +000016 return workloadFactory.CreateWorkload(armnn::LayerType::Minimum, descriptor, info);
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +010017}
18
19LayerTestResult<float, 4> MinimumBroadcast1ElementTest1(
20 armnn::IWorkloadFactory& workloadFactory,
Keith Davis33a626f2020-08-27 15:38:12 +010021 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
22 const armnn::ITensorHandleFactory& tensorHandleFactory)
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +010023{
Jan Eilers8eb25602020-03-09 12:13:48 +000024 IgnoreUnused(memoryManager);
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +010025 unsigned int shape0[] = { 1, 2, 2, 2 };
26 unsigned int shape1[] = { 1, 1, 1, 1 };
27
28 std::vector<float> input0 = { 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f };
29
30 std::vector<float> input1 = { 2.f };
31
32 std::vector<float> output = { 1.f, 2.f, 2.f, 2.f, 2.f, 2.f, 2.f, 2.f };
33
34 return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float32>(
35 workloadFactory,
36 memoryManager,
37 shape0,
38 input0,
39 shape1,
40 input1,
41 shape0,
Keith Davis33a626f2020-08-27 15:38:12 +010042 output,
43 tensorHandleFactory);
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +010044}
45
46LayerTestResult<float, 4> MinimumBroadcast1ElementTest2(
47 armnn::IWorkloadFactory& workloadFactory,
Keith Davis33a626f2020-08-27 15:38:12 +010048 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
49 const armnn::ITensorHandleFactory& tensorHandleFactory)
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +010050{
51 unsigned int shape0[] = { 1, 2, 2, 2 };
52 unsigned int shape1[] = { 1, 1, 1, 1 };
53
54 std::vector<float> input0 = { 1.f, 6.f, 3.f, 2.f, 8.f, 9.f, 1.f, 10.f };
55
56 std::vector<float> input1 = { 5.f };
57
58 std::vector<float> output = { 1.f, 5.f, 3.f, 2.f, 5.f, 5.f, 1.f, 5.f };
59
60 return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float32>(
61 workloadFactory,
62 memoryManager,
63 shape0,
64 input0,
65 shape1,
66 input1,
67 shape0,
Keith Davis33a626f2020-08-27 15:38:12 +010068 output,
69 tensorHandleFactory);
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +010070}
71
72LayerTestResult<uint8_t, 4> MinimumBroadcast1DVectorUint8Test(
73 armnn::IWorkloadFactory & workloadFactory,
Keith Davis33a626f2020-08-27 15:38:12 +010074 const armnn::IBackendInternal::IMemoryManagerSharedPtr & memoryManager,
75 const armnn::ITensorHandleFactory& tensorHandleFactory)
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +010076{
77 const unsigned int shape0[] = { 1, 2, 2, 3 };
78 const unsigned int shape1[] = { 1, 1, 1, 3 };
79
80 std::vector<uint8_t> input0 =
81 {
82 1, 2, 3, 3, 2, 1,
83 7, 1, 2, 3, 4, 5
84 };
85
86 std::vector<uint8_t> input1 = { 1, 2, 3 };
87
88 std::vector<uint8_t> output =
89 {
90 1, 2, 3, 1, 2, 1,
91 1, 1, 2, 1, 2, 3
92 };
93
Derek Lambertif90c56d2020-01-10 17:14:08 +000094 return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QAsymmU8>(
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +010095 workloadFactory,
96 memoryManager,
97 shape0,
98 input0,
99 shape1,
100 input1,
101 shape0,
Keith Davis33a626f2020-08-27 15:38:12 +0100102 output,
103 tensorHandleFactory);
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +0100104}
105
Matthew Jackson9bff1442019-09-12 09:08:23 +0100106LayerTestResult<armnn::Half, 4> MinimumFloat16Test(
107 armnn::IWorkloadFactory& workloadFactory,
Keith Davis33a626f2020-08-27 15:38:12 +0100108 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
109 const armnn::ITensorHandleFactory& tensorHandleFactory)
Matthew Jackson9bff1442019-09-12 09:08:23 +0100110{
111 using namespace half_float::literal;
112
113 unsigned int shape[] = { 2, 2, 2, 2 };
114
115 std::vector<armnn::Half> input0 =
116 {
117 1._h, 1._h, 1._h, 1._h, 6._h, 6._h, 6._h, 6._h,
118 3._h, 3._h, 3._h, 3._h, 4._h, 4._h, 4._h, 4._h
119 };
120
121 std::vector<armnn::Half> input1 =
122 {
123 2._h, 2._h, 2._h, 2._h, 3._h, 3._h, 3._h, 3._h,
124 4._h, 4._h, 4._h, 4._h, 5._h, 5._h, 5._h, 5._h
125 };
126
127 std::vector<armnn::Half> output
128 {
129 1._h, 1._h, 1._h, 1._h, 3._h, 3._h, 3._h, 3._h,
130 3._h, 3._h, 3._h, 3._h, 4._h, 4._h, 4._h, 4._h
131 };
132
133 return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float16>(
134 workloadFactory,
135 memoryManager,
136 shape,
137 input0,
138 shape,
139 input1,
140 shape,
Keith Davis33a626f2020-08-27 15:38:12 +0100141 output,
142 tensorHandleFactory);
Matthew Jackson9bff1442019-09-12 09:08:23 +0100143}
144
145LayerTestResult<armnn::Half, 4> MinimumBroadcast1ElementFloat16Test(
146 armnn::IWorkloadFactory& workloadFactory,
Keith Davis33a626f2020-08-27 15:38:12 +0100147 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
148 const armnn::ITensorHandleFactory& tensorHandleFactory)
Matthew Jackson9bff1442019-09-12 09:08:23 +0100149{
150 using namespace half_float::literal;
151
152 const unsigned int shape0[] = { 1, 2, 2, 3 };
153 const unsigned int shape1[] = { 1, 1, 1, 1 };
154
155 std::vector<armnn::Half> input0 =
156 {
157 1._h, 2._h, 3._h, 4._h, 5._h, 6._h,
158 7._h, 8._h, 9._h, 10._h, 11._h, 12._h
159 };
160
161 std::vector<armnn::Half> input1 = { 2._h };
162
163 std::vector<armnn::Half> output =
164 {
165 1._h, 2._h, 2._h, 2._h, 2._h, 2._h,
166 2._h, 2._h, 2._h, 2._h, 2._h, 2._h
167 };
168
169 return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float16>(
170 workloadFactory,
171 memoryManager,
172 shape0,
173 input0,
174 shape1,
175 input1,
176 shape0,
Keith Davis33a626f2020-08-27 15:38:12 +0100177 output,
178 tensorHandleFactory);
Matthew Jackson9bff1442019-09-12 09:08:23 +0100179}
180
181LayerTestResult<armnn::Half, 4> MinimumBroadcast1DVectorFloat16Test(
182 armnn::IWorkloadFactory& workloadFactory,
Keith Davis33a626f2020-08-27 15:38:12 +0100183 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
184 const armnn::ITensorHandleFactory& tensorHandleFactory)
Matthew Jackson9bff1442019-09-12 09:08:23 +0100185{
186 using namespace half_float::literal;
Matthew Jackson9bff1442019-09-12 09:08:23 +0100187 const unsigned int shape0[] = { 1, 2, 2, 3 };
188 const unsigned int shape1[] = { 1, 1, 1, 3 };
189
190 std::vector<armnn::Half> input0 =
191 {
192 1._h, 2._h, 3._h, 4._h, 5._h, 6._h,
193 7._h, 8._h, 9._h, 10._h, 11._h, 12._h
194 };
195
196 std::vector<armnn::Half> input1 = { 1._h, 10._h, 3._h };
197
198 std::vector<armnn::Half> output =
199 {
200 1._h, 2._h, 3._h, 1._h, 5._h, 3._h,
201 1._h, 8._h, 3._h, 1._h, 10._h, 3._h
202 };
203
204 return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float16>(
205 workloadFactory,
206 memoryManager,
207 shape0,
208 input0,
209 shape1,
210 input1,
211 shape0,
Keith Davis33a626f2020-08-27 15:38:12 +0100212 output,
213 tensorHandleFactory);
Matthew Jackson9bff1442019-09-12 09:08:23 +0100214}
215
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +0100216LayerTestResult<int16_t, 4> MinimumInt16Test(
217 armnn::IWorkloadFactory& workloadFactory,
Keith Davis33a626f2020-08-27 15:38:12 +0100218 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
219 const armnn::ITensorHandleFactory& tensorHandleFactory)
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +0100220{
221 unsigned int shape[] = { 2, 2, 2, 2 };
222
223 std::vector<int16_t> input0 =
224 {
225 1, 1, 1, 1, 6, 6, 6, 6,
226 3, 3, 3, 3, 4, 4, 4, 4
227 };
228
229 std::vector<int16_t> input1 =
230 {
231 2, 2, 2, 2, 3, 3, 3, 3,
232 4, 4, 4, 4, 5, 5, 5, 5
233 };
234
235 std::vector<int16_t> output
236 {
237 1, 1, 1, 1, 3, 3, 3, 3,
238 3, 3, 3, 3, 4, 4, 4, 4
239 };
240
Derek Lambertif90c56d2020-01-10 17:14:08 +0000241 return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QSymmS16>(
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +0100242 workloadFactory,
243 memoryManager,
244 shape,
245 input0,
246 shape,
247 input1,
248 shape,
Keith Davis33a626f2020-08-27 15:38:12 +0100249 output,
250 tensorHandleFactory);
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +0100251}
252
253LayerTestResult<int16_t, 4> MinimumBroadcast1ElementInt16Test(
254 armnn::IWorkloadFactory& workloadFactory,
Keith Davis33a626f2020-08-27 15:38:12 +0100255 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
256 const armnn::ITensorHandleFactory& tensorHandleFactory)
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +0100257{
258 const unsigned int shape0[] = { 1, 2, 2, 3 };
259 const unsigned int shape1[] = { 1, 1, 1, 1 };
260
261 std::vector<int16_t> input0 =
262 {
263 1, 2, 3, 4, 5, 6,
264 7, 8, 9, 10, 11, 12
265 };
266
267 std::vector<int16_t> input1 = { 2 };
268
269 std::vector<int16_t> output =
270 {
271 1, 2, 2, 2, 2, 2,
272 2, 2, 2, 2, 2, 2
273 };
274
Derek Lambertif90c56d2020-01-10 17:14:08 +0000275 return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QSymmS16>(
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +0100276 workloadFactory,
277 memoryManager,
278 shape0,
279 input0,
280 shape1,
281 input1,
282 shape0,
Keith Davis33a626f2020-08-27 15:38:12 +0100283 output,
284 tensorHandleFactory);
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +0100285}
286
287LayerTestResult<int16_t, 4> MinimumBroadcast1DVectorInt16Test(
288 armnn::IWorkloadFactory& workloadFactory,
Keith Davis33a626f2020-08-27 15:38:12 +0100289 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
290 const armnn::ITensorHandleFactory& tensorHandleFactory)
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +0100291{
292 const unsigned int shape0[] = { 1, 2, 2, 3 };
293 const unsigned int shape1[] = { 1, 1, 1, 3 };
294
295 std::vector<int16_t> input0 =
296 {
297 1, 2, 3, 4, 5, 6,
298 7, 8, 9, 10, 11, 12
299 };
300
301 std::vector<int16_t> input1 = { 1, 10, 3 };
302
303 std::vector<int16_t> output =
304 {
305 1, 2, 3, 1, 5, 3,
306 1, 8, 3, 1, 10, 3
307 };
308
Derek Lambertif90c56d2020-01-10 17:14:08 +0000309 return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QSymmS16>(
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +0100310 workloadFactory,
311 memoryManager,
312 shape0,
313 input0,
314 shape1,
315 input1,
316 shape0,
Keith Davis33a626f2020-08-27 15:38:12 +0100317 output,
318 tensorHandleFactory);
Aron Virginas-Tare89ebad2019-08-27 18:14:26 +0100319}
Teresa Charlinecb6b8e2020-05-22 18:08:23 +0100320
321LayerTestResult<int32_t, 4> MinimumInt32Test(
322 armnn::IWorkloadFactory& workloadFactory,
Keith Davis33a626f2020-08-27 15:38:12 +0100323 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
324 const armnn::ITensorHandleFactory& tensorHandleFactory)
Teresa Charlinecb6b8e2020-05-22 18:08:23 +0100325{
326 unsigned int shape[] = { 2, 2, 2, 2 };
327
328 std::vector<int32_t> input0 =
329 {
330 1, 1, 1, 1, 6, 6, 6, 6,
331 3, 3, 3, 3, 4, 4, 4, 4
332 };
333
334 std::vector<int32_t> input1 =
335 {
336 2, 2, 2, 2, 3, 3, 3, 3,
337 4, 4, 4, 4, 5, 5, 5, 5
338 };
339
340 std::vector<int32_t> output
341 {
342 1, 1, 1, 1, 3, 3, 3, 3,
343 3, 3, 3, 3, 4, 4, 4, 4
344 };
345
346 return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Signed32>(
347 workloadFactory,
348 memoryManager,
349 shape,
350 input0,
351 shape,
352 input1,
353 shape,
Keith Davis33a626f2020-08-27 15:38:12 +0100354 output,
355 tensorHandleFactory);
Teresa Charlinecb6b8e2020-05-22 18:08:23 +0100356}
357
358LayerTestResult<int32_t, 4> MinimumBroadcast1ElementInt32Test(
359 armnn::IWorkloadFactory& workloadFactory,
Keith Davis33a626f2020-08-27 15:38:12 +0100360 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
361 const armnn::ITensorHandleFactory& tensorHandleFactory)
Teresa Charlinecb6b8e2020-05-22 18:08:23 +0100362{
363 const unsigned int shape0[] = { 1, 2, 2, 3 };
364 const unsigned int shape1[] = { 1, 1, 1, 1 };
365
366 std::vector<int32_t> input0 =
367 {
368 1, 2, 3, 4, 5, 6,
369 7, 8, 9, 10, 11, 12
370 };
371
372 std::vector<int32_t> input1 = { 2 };
373
374 std::vector<int32_t> output =
375 {
376 1, 2, 2, 2, 2, 2,
377 2, 2, 2, 2, 2, 2
378 };
379
380 return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Signed32>(
381 workloadFactory,
382 memoryManager,
383 shape0,
384 input0,
385 shape1,
386 input1,
387 shape0,
Keith Davis33a626f2020-08-27 15:38:12 +0100388 output,
389 tensorHandleFactory);
Teresa Charlinecb6b8e2020-05-22 18:08:23 +0100390}
391
392LayerTestResult<int32_t, 4> MinimumBroadcast1DVectorInt32Test(
393 armnn::IWorkloadFactory& workloadFactory,
Keith Davis33a626f2020-08-27 15:38:12 +0100394 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
395 const armnn::ITensorHandleFactory& tensorHandleFactory)
Teresa Charlinecb6b8e2020-05-22 18:08:23 +0100396{
397 const unsigned int shape0[] = { 1, 2, 2, 3 };
398 const unsigned int shape1[] = { 1, 1, 1, 3 };
399
400 std::vector<int32_t> input0 =
401 {
402 1, 2, 3, 4, 5, 6,
403 7, 8, 9, 10, 11, 12
404 };
405
406 std::vector<int32_t> input1 = { 1, 10, 3 };
407
408 std::vector<int32_t> output =
409 {
410 1, 2, 3, 1, 5, 3,
411 1, 8, 3, 1, 10, 3
412 };
413
414 return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Signed32>(
415 workloadFactory,
416 memoryManager,
417 shape0,
418 input0,
419 shape1,
420 input1,
421 shape0,
Keith Davis33a626f2020-08-27 15:38:12 +0100422 output,
423 tensorHandleFactory);
Teresa Charlinecb6b8e2020-05-22 18:08:23 +0100424}