ArmNN
 21.02
MaximumTestImpl.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "MaximumTestImpl.hpp"
7 
9 
10 template<>
11 std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::MaximumQueueDescriptor>(
12  const armnn::IWorkloadFactory& workloadFactory,
13  const armnn::WorkloadInfo& info,
14  const armnn::MaximumQueueDescriptor& descriptor)
15 {
16  return workloadFactory.CreateMaximum(descriptor, info);
17 }
18 
20  armnn::IWorkloadFactory& workloadFactory,
22  const armnn::ITensorHandleFactory& tensorHandleFactory)
23 {
24  IgnoreUnused(memoryManager);
25  const unsigned int width = 2u;
26  const unsigned int height = 2u;
27  const unsigned int channelCount = 2u;
28  const unsigned int batchSize = 2u;
29 
30  unsigned int shape[] = { batchSize, channelCount, height, width };
31 
32  std::vector<float> input0 =
33  {
34  1.f, 1.f, 1.f, 1.f, 5.f, 5.f, 5.f, 5.f,
35  3.f, 3.f, 3.f, 3.f, 4.f, 4.f, 4.f, 4.f
36  };
37 
38  std::vector<float> input1 =
39  {
40  2.f, 2.f, 2.f, 2.f, 3.f, 3.f, 3.f, 3.f,
41  4.f, 4.f, 4.f, 4.f, 5.f, 5.f, 5.f, 5.f
42  };
43 
44  std::vector<float> output =
45  {
46  2.f, 2.f, 2.f, 2.f, 5.f, 5.f, 5.f, 5.f,
47  4.f, 4.f, 4.f, 4.f, 5.f, 5.f, 5.f, 5.f
48  };
49 
50  return ElementwiseTestHelper<4, armnn::MaximumQueueDescriptor, armnn::DataType::Float32>(
51  workloadFactory,
52  memoryManager,
53  shape,
54  input0,
55  shape,
56  input1,
57  shape,
58  output,
59  tensorHandleFactory);
60 }
61 
63  armnn::IWorkloadFactory& workloadFactory,
65  const armnn::ITensorHandleFactory& tensorHandleFactory)
66 {
67  unsigned int shape0[] = { 1, 2, 2, 2 };
68  unsigned int shape1[] = { 1, 1, 1, 1 };
69 
70  std::vector<float> input0 = { 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f };
71 
72  std::vector<float> input1 = { 2.f };
73 
74  std::vector<float> output = { 2.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f };
75 
76  return ElementwiseTestHelper<4, armnn::MaximumQueueDescriptor, armnn::DataType::Float32>(
77  workloadFactory,
78  memoryManager,
79  shape0,
80  input0,
81  shape1,
82  input1,
83  shape0,
84  output,
85  tensorHandleFactory);
86 }
87 
89  armnn::IWorkloadFactory& workloadFactory,
91  const armnn::ITensorHandleFactory& tensorHandleFactory)
92 {
93  const unsigned int shape0[] = { 1, 2, 2, 3 };
94  const unsigned int shape1[] = { 1, 1, 1, 3 };
95 
96  std::vector<float> input0 =
97  {
98  1.f, 2.f, 3.f, 4.f, 5.f, 6.f,
99  7.f, 8.f, 9.f, 10.f, 11.f, 12.f
100  };
101 
102  std::vector<float> input1 = { 1.f, 2.f, 3.f };
103 
104  std::vector<float> output =
105  {
106  1.f, 2.f, 3.f, 4.f, 5.f, 6.f,
107  7.f, 8.f, 9.f, 10.f, 11.f, 12.f
108  };
109 
110  return ElementwiseTestHelper<4, armnn::MaximumQueueDescriptor, armnn::DataType::Float32>(
111  workloadFactory,
112  memoryManager,
113  shape0,
114  input0,
115  shape1,
116  input1,
117  shape0,
118  output,
119  tensorHandleFactory);
120 }
121 
123  armnn::IWorkloadFactory& workloadFactory,
125  const armnn::ITensorHandleFactory& tensorHandleFactory)
126 {
127  using namespace half_float::literal;
128 
129  const unsigned int width = 2u;
130  const unsigned int height = 2u;
131  const unsigned int channelCount = 2u;
132  const unsigned int batchSize = 2u;
133 
134  unsigned int shape[] = { batchSize, channelCount, height, width };
135 
136  std::vector<armnn::Half> input0 =
137  {
138  1._h, 1._h, 1._h, 1._h, 5._h, 5._h, 5._h, 5._h,
139  3._h, 3._h, 3._h, 3._h, 4._h, 4._h, 4._h, 4._h
140  };
141 
142  std::vector<armnn::Half> input1 =
143  {
144  2._h, 2._h, 2._h, 2._h, 3._h, 3._h, 3._h, 3._h,
145  4._h, 4._h, 4._h, 4._h, 5._h, 5._h, 5._h, 5._h
146  };
147 
148  std::vector<armnn::Half> output =
149  {
150  2._h, 2._h, 2._h, 2._h, 5._h, 5._h, 5._h, 5._h,
151  4._h, 4._h, 4._h, 4._h, 5._h, 5._h, 5._h, 5._h
152  };
153 
154  return ElementwiseTestHelper<4, armnn::MaximumQueueDescriptor, armnn::DataType::Float16>(
155  workloadFactory,
156  memoryManager,
157  shape,
158  input0,
159  shape,
160  input1,
161  shape,
162  output,
163  tensorHandleFactory);
164 }
165 
167  armnn::IWorkloadFactory& workloadFactory,
169  const armnn::ITensorHandleFactory& tensorHandleFactory)
170 {
171  using namespace half_float::literal;
172 
173  unsigned int shape0[] = { 1, 2, 2, 2 };
174  unsigned int shape1[] = { 1, 1, 1, 1 };
175 
176  std::vector<armnn::Half> input0 = { 1._h, 2._h, 3._h, 4._h, 5._h, 6._h, 7._h, 8._h };
177 
178  std::vector<armnn::Half> input1 = { 2._h };
179 
180  std::vector<armnn::Half> output = { 2._h, 2._h, 3._h, 4._h, 5._h, 6._h, 7._h, 8._h };
181 
182  return ElementwiseTestHelper<4, armnn::MaximumQueueDescriptor, armnn::DataType::Float16>(
183  workloadFactory,
184  memoryManager,
185  shape0,
186  input0,
187  shape1,
188  input1,
189  shape0,
190  output,
191  tensorHandleFactory);
192 }
193 
195  armnn::IWorkloadFactory& workloadFactory,
197  const armnn::ITensorHandleFactory& tensorHandleFactory)
198 {
199  using namespace half_float::literal;
200 
201  const unsigned int shape0[] = { 1, 2, 2, 3 };
202  const unsigned int shape1[] = { 1, 1, 1, 3 };
203 
204  std::vector<armnn::Half> input0 =
205  {
206  1._h, 2._h, 3._h, 4._h, 5._h, 6._h,
207  7._h, 8._h, 9._h, 10._h, 11._h, 12._h
208  };
209 
210  std::vector<armnn::Half> input1 = { 1._h, 2._h, 3._h };
211 
212  std::vector<armnn::Half> output =
213  {
214  1._h, 2._h, 3._h, 4._h, 5._h, 6._h,
215  7._h, 8._h, 9._h, 10._h, 11._h, 12._h
216  };
217 
218  return ElementwiseTestHelper<4, armnn::MaximumQueueDescriptor, armnn::DataType::Float16>(
219  workloadFactory,
220  memoryManager,
221  shape0,
222  input0,
223  shape1,
224  input1,
225  shape0,
226  output,
227  tensorHandleFactory);
228 }
229 
231  armnn::IWorkloadFactory& workloadFactory,
233  const armnn::ITensorHandleFactory& tensorHandleFactory)
234 {
235  unsigned int shape[] = { 2, 2, 2, 2 };
236 
237  // See dequantized values to the right.
238  std::vector<uint8_t> input0 =
239  {
240  1, 1, 1, 1, 6, 6, 6, 6,
241  3, 3, 3, 3, 4, 4, 4, 4
242  };
243 
244  std::vector<uint8_t> input1 =
245  {
246  2, 2, 2, 2, 3, 3, 3, 3,
247  4, 4, 4, 4, 5, 5, 5, 5
248  };
249 
250  std::vector<uint8_t> output =
251  {
252  2, 2, 2, 2, 6, 6, 6, 6,
253  4, 4, 4, 4, 5, 5, 5, 5
254  };
255 
256  return ElementwiseTestHelper<4, armnn::MaximumQueueDescriptor, armnn::DataType::QAsymmU8>(
257  workloadFactory,
258  memoryManager,
259  shape,
260  input0,
261  shape,
262  input1,
263  shape,
264  output,
265  tensorHandleFactory);
266 }
267 
269  armnn::IWorkloadFactory& workloadFactory,
271  const armnn::ITensorHandleFactory& tensorHandleFactory)
272 {
273  const unsigned int shape0[] = { 1, 2, 2, 3 };
274  const unsigned int shape1[] = { 1, 1, 1, 1 };
275 
276  std::vector<uint8_t> input0 =
277  {
278  1, 2, 3, 4, 5, 6,
279  7, 8, 9, 10, 11, 12
280  };
281 
282  std::vector<uint8_t> input1 = { 2 };
283 
284  std::vector<uint8_t> output =
285  {
286  2, 2, 3, 4, 5, 6,
287  7, 8, 9, 10, 11, 12
288  };
289 
290  return ElementwiseTestHelper<4, armnn::MaximumQueueDescriptor, armnn::DataType::QAsymmU8>(
291  workloadFactory,
292  memoryManager,
293  shape0,
294  input0,
295  shape1,
296  input1,
297  shape0,
298  output,
299  tensorHandleFactory);
300 }
301 
303  armnn::IWorkloadFactory& workloadFactory,
305  const armnn::ITensorHandleFactory& tensorHandleFactory)
306 {
307  const unsigned int shape0[] = { 1, 2, 2, 3 };
308  const unsigned int shape1[] = { 1, 1, 1, 3 };
309 
310  std::vector<uint8_t> input0 =
311  {
312  1, 2, 3, 4, 5, 6,
313  7, 8, 9, 10, 11, 12
314  };
315 
316  std::vector<uint8_t> input1 = { 1, 10, 3 };
317 
318  std::vector<uint8_t> output = {
319  1, 10, 3, 4, 10, 6,
320  7, 10, 9, 10, 11, 12
321  };
322 
323  return ElementwiseTestHelper<4, armnn::MaximumQueueDescriptor, armnn::DataType::QAsymmU8>(
324  workloadFactory,
325  memoryManager,
326  shape0,
327  input0,
328  shape1,
329  input1,
330  shape0,
331  output,
332  tensorHandleFactory);
333 }
334 
336  armnn::IWorkloadFactory& workloadFactory,
338  const armnn::ITensorHandleFactory& tensorHandleFactory)
339 {
340  unsigned int shape[] = { 2, 2, 2, 2 };
341 
342  std::vector<int16_t> input0({ 1, 1, 1, 1, 6, 6, 6, 6,
343  3, 3, 3, 3, 4, 4, 4, 4 });
344 
345  std::vector<int16_t> input1({ 2, 2, 2, 2, 3, 3, 3, 3,
346  4, 4, 4, 4, 5, 5, 5, 5 });
347 
348  std::vector<int16_t> output({ 2, 2, 2, 2, 6, 6, 6, 6,
349  4, 4, 4, 4, 5, 5, 5, 5 });
350 
351  return ElementwiseTestHelper<4, armnn::MaximumQueueDescriptor, armnn::DataType::QSymmS16>(
352  workloadFactory,
353  memoryManager,
354  shape,
355  input0,
356  shape,
357  input1,
358  shape,
359  output,
360  tensorHandleFactory);
361 }
362 
364  armnn::IWorkloadFactory& workloadFactory,
366  const armnn::ITensorHandleFactory& tensorHandleFactory)
367 {
368  const unsigned int shape0[] = { 1, 2, 2, 3 };
369  const unsigned int shape1[] = { 1, 1, 1, 1 };
370 
371  std::vector<int16_t> input0 =
372  {
373  1, 2, 3, 4, 5, 6,
374  7, 8, 9, 10, 11, 12
375  };
376 
377  std::vector<int16_t> input1 = { 2 };
378 
379  std::vector<int16_t> output =
380  {
381  2, 2, 3, 4, 5, 6,
382  7, 8, 9, 10, 11, 12
383  };
384 
385  return ElementwiseTestHelper<4, armnn::MaximumQueueDescriptor, armnn::DataType::QSymmS16>(
386  workloadFactory,
387  memoryManager,
388  shape0,
389  input0,
390  shape1,
391  input1,
392  shape0,
393  output,
394  tensorHandleFactory);
395 }
396 
398  armnn::IWorkloadFactory& workloadFactory,
400  const armnn::ITensorHandleFactory& tensorHandleFactory)
401 {
402  const unsigned int shape0[] = { 1, 2, 2, 3 };
403  const unsigned int shape1[] = { 1, 1, 1, 3 };
404 
405  std::vector<int16_t> input0 =
406  {
407  1, 2, 3, 4, 5, 6,
408  7, 8, 9, 10, 11, 12
409  };
410 
411  std::vector<int16_t> input1 = { 1, 10, 3 };
412 
413  std::vector<int16_t> output =
414  {
415  1, 10, 3, 4, 10, 6,
416  7, 10, 9, 10, 11, 12
417  };
418 
419  return ElementwiseTestHelper<4, armnn::MaximumQueueDescriptor, armnn::DataType::QSymmS16>(
420  workloadFactory,
421  memoryManager,
422  shape0,
423  input0,
424  shape1,
425  input1,
426  shape0,
427  output,
428  tensorHandleFactory);
429 }
430 
432  armnn::IWorkloadFactory& workloadFactory,
434  const armnn::ITensorHandleFactory& tensorHandleFactory)
435 {
436  unsigned int shape[] = { 2, 2, 2, 2 };
437 
438  std::vector<int32_t> input0({ 1, 1, 1, 1, 6, 6, 6, 6,
439  3, 3, 3, 3, 4, 4, 4, 4 });
440 
441  std::vector<int32_t> input1({ 2, 2, 2, 2, 3, 3, 3, 3,
442  4, 4, 4, 4, 5, 5, 5, 5 });
443 
444  std::vector<int32_t> output({ 2, 2, 2, 2, 6, 6, 6, 6,
445  4, 4, 4, 4, 5, 5, 5, 5 });
446 
447  return ElementwiseTestHelper<4, armnn::MaximumQueueDescriptor, armnn::DataType::Signed32>(
448  workloadFactory,
449  memoryManager,
450  shape,
451  input0,
452  shape,
453  input1,
454  shape,
455  output,
456  tensorHandleFactory);
457 }
458 
460  armnn::IWorkloadFactory& workloadFactory,
462  const armnn::ITensorHandleFactory& tensorHandleFactory)
463 {
464  const unsigned int shape0[] = { 1, 2, 2, 3 };
465  const unsigned int shape1[] = { 1, 1, 1, 1 };
466 
467  std::vector<int32_t> input0 =
468  {
469  1, 2, 3, 4, 5, 6,
470  7, 8, 9, 10, 11, 12
471  };
472 
473  std::vector<int32_t> input1 = { 2 };
474 
475  std::vector<int32_t> output =
476  {
477  2, 2, 3, 4, 5, 6,
478  7, 8, 9, 10, 11, 12
479  };
480 
481  return ElementwiseTestHelper<4, armnn::MaximumQueueDescriptor, armnn::DataType::Signed32>(
482  workloadFactory,
483  memoryManager,
484  shape0,
485  input0,
486  shape1,
487  input1,
488  shape0,
489  output,
490  tensorHandleFactory);
491 }
492 
494  armnn::IWorkloadFactory& workloadFactory,
496  const armnn::ITensorHandleFactory& tensorHandleFactory)
497 {
498  const unsigned int shape0[] = { 1, 2, 2, 3 };
499  const unsigned int shape1[] = { 1, 1, 1, 3 };
500 
501  std::vector<int32_t> input0 =
502  {
503  1, 2, 3, 4, 5, 6,
504  7, 8, 9, 10, 11, 12
505  };
506 
507  std::vector<int32_t> input1 = { 1, 10, 3 };
508 
509  std::vector<int32_t> output =
510  {
511  1, 10, 3, 4, 10, 6,
512  7, 10, 9, 10, 11, 12
513  };
514 
515  return ElementwiseTestHelper<4, armnn::MaximumQueueDescriptor, armnn::DataType::Signed32>(
516  workloadFactory,
517  memoryManager,
518  shape0,
519  input0,
520  shape1,
521  input1,
522  shape0,
523  output,
524  tensorHandleFactory);
525 }
LayerTestResult< armnn::Half, 4 > MaximumBroadcast1ElementFloat16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< float, 4 > MaximumBroadcast1ElementTest(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< int32_t, 4 > MaximumBroadcast1DVectorInt32Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< armnn::Half, 4 > MaximumFloat16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< int16_t, 4 > MaximumInt16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< int16_t, 4 > MaximumBroadcast1ElementInt16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
void IgnoreUnused(Ts &&...)
LayerTestResult< armnn::Half, 4 > MaximumBroadcast1DVectorFloat16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< float, 4 > MaximumBroadcast1DVectorTest(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< int32_t, 4 > MaximumBroadcast1ElementInt32Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
LayerTestResult< float, 4 > MaximumSimpleTest(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< uint8_t, 4 > MaximumUint8Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< uint8_t, 4 > MaximumBroadcast1ElementUint8Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< int32_t, 4 > MaximumInt32Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< int16_t, 4 > MaximumBroadcast1DVectorInt16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
Contains information about inputs and outputs to a layer.
LayerTestResult< uint8_t, 4 > MaximumBroadcast1DVectorUint8Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)