ArmNN
 20.02
DivisionTestImpl.cpp File Reference

Go to the source code of this file.

Functions

template<>
std::unique_ptr< armnn::IWorkloadCreateWorkload< armnn::DivisionQueueDescriptor > (const armnn::IWorkloadFactory &workloadFactory, const armnn::WorkloadInfo &info, const armnn::DivisionQueueDescriptor &descriptor)
 
LayerTestResult< float, 4 > DivisionByZeroTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager)
 
LayerTestResult< float, 4 > DivisionTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager)
 
LayerTestResult< float, 4 > DivisionBroadcast1ElementTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager)
 
LayerTestResult< float, 4 > DivisionBroadcast1DVectorTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager)
 
LayerTestResult< armnn::Half, 4 > DivisionFloat16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager)
 
LayerTestResult< armnn::Half, 4 > DivisionBroadcast1ElementFloat16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager)
 
LayerTestResult< armnn::Half, 4 > DivisionBroadcast1DVectorFloat16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager)
 
LayerTestResult< uint8_t, 4 > DivisionUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager)
 
LayerTestResult< uint8_t, 4 > DivisionBroadcast1ElementUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager)
 
LayerTestResult< uint8_t, 4 > DivisionBroadcast1DVectorUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager)
 
LayerTestResult< int16_t, 4 > DivisionInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager)
 
LayerTestResult< int16_t, 4 > DivisionBroadcast1ElementInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager)
 
LayerTestResult< int16_t, 4 > DivisionBroadcast1DVectorInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager)
 

Function Documentation

◆ CreateWorkload< armnn::DivisionQueueDescriptor >()

std::unique_ptr<armnn::IWorkload> CreateWorkload< armnn::DivisionQueueDescriptor > ( const armnn::IWorkloadFactory workloadFactory,
const armnn::WorkloadInfo info,
const armnn::DivisionQueueDescriptor descriptor 
)

Definition at line 11 of file DivisionTestImpl.cpp.

15 {
16  return workloadFactory.CreateDivision(descriptor, info);
17 }
virtual std::unique_ptr< IWorkload > CreateDivision(const DivisionQueueDescriptor &descriptor, const WorkloadInfo &info) const

◆ DivisionBroadcast1DVectorFloat16Test()

LayerTestResult<armnn::Half, 4> DivisionBroadcast1DVectorFloat16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager 
)

Definition at line 226 of file DivisionTestImpl.cpp.

229 {
230  using namespace half_float::literal;
231 
232  unsigned int shape0[] = { 1, 3, 3, 2 };
233  unsigned int shape1[] = { 1, 1, 1, 2 };
234 
235  std::vector<armnn::Half> input0 =
236  {
237  1._h, 4._h, 3._h, 8._h, 5._h, 12._h,
238  7._h, 16._h, 9._h, 20._h, 11._h, 24._h,
239  13._h, 28._h, 15._h, 32._h, 17._h, 36._h
240  };
241 
242  std::vector<armnn::Half> input1 = { 1._h, 2._h };
243 
244  std::vector<armnn::Half> output =
245  {
246  1._h, 2._h, 3._h, 4._h, 5._h, 6._h,
247  7._h, 8._h, 9._h, 10._h, 11._h, 12._h,
248  13._h, 14._h, 15._h, 16._h, 17._h, 18._h
249  };
250 
251  return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Float16>(
252  workloadFactory,
253  memoryManager,
254  shape0,
255  input0,
256  shape1,
257  input1,
258  shape0,
259  output);
260 }

◆ DivisionBroadcast1DVectorInt16Test()

LayerTestResult<int16_t, 4> DivisionBroadcast1DVectorInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager 
)

Definition at line 423 of file DivisionTestImpl.cpp.

426 {
427  unsigned int shape0[] = { 1, 3, 3, 2 };
428  unsigned int shape1[] = { 1, 1, 1, 2 };
429 
430  std::vector<int16_t> input0 =
431  {
432  1, 4, 3, 8, 5, 12,
433  7, 16, 9, 20, 11, 24,
434  13, 28, 15, 32, 17, 36
435  };
436 
437  std::vector<int16_t> input1 = { 1, 2 };
438 
439  std::vector<int16_t> output =
440  {
441  1, 2, 3, 4, 5, 6,
442  7, 8, 9, 10, 11, 12,
443  13, 14, 15, 16, 17, 18
444  };
445 
446  return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::QSymmS16>(
447  workloadFactory,
448  memoryManager,
449  shape0,
450  input0,
451  shape1,
452  input1,
453  shape0,
454  output);
455 }

◆ DivisionBroadcast1DVectorTest()

LayerTestResult<float, 4> DivisionBroadcast1DVectorTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager 
)

Definition at line 124 of file DivisionTestImpl.cpp.

127 {
128  unsigned int shape0[] = { 1, 3, 3, 2 };
129  unsigned int shape1[] = { 1, 1, 1, 2 };
130 
131  std::vector<float> input0 =
132  {
133  1.f, 4.f, 3.f, 8.f, 5.f, 12.f,
134  7.f, 16.f, 9.f, 20.f, 11.f, 24.f,
135  13.f, 28.f, 15.f, 32.f, 17.f, 36.f
136  };
137 
138  std::vector<float> input1 = { 1.f, 2.f };
139 
140  std::vector<float> output =
141  {
142  1.f, 2.f, 3.f, 4.f, 5.f, 6.f,
143  7.f, 8.f, 9.f, 10.f, 11.f, 12.f,
144  13.f, 14.f, 15.f, 16.f, 17.f, 18.f
145  };
146 
147  return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Float32>(
148  workloadFactory,
149  memoryManager,
150  shape0,
151  input0,
152  shape1,
153  input1,
154  shape0,
155  output);
156 }

◆ DivisionBroadcast1DVectorUint8Test()

LayerTestResult<uint8_t, 4> DivisionBroadcast1DVectorUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager 
)

Definition at line 328 of file DivisionTestImpl.cpp.

331 {
332  unsigned int shape0[] = { 1, 3, 3, 2 };
333  unsigned int shape1[] = { 1, 1, 1, 2 };
334 
335  std::vector<uint8_t> input0 =
336  {
337  1, 4, 3, 8, 5, 12,
338  7, 16, 9, 20, 11, 24,
339  13, 28, 15, 32, 17, 36
340  };
341 
342  std::vector<uint8_t> input1 = { 1, 2 };
343 
344  std::vector<uint8_t> output =
345  {
346  1, 2, 3, 4, 5, 6,
347  7, 8, 9, 10, 11, 12,
348  13, 14, 15, 16, 17, 18
349  };
350 
351  return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::QAsymmU8>(
352  workloadFactory,
353  memoryManager,
354  shape0,
355  input0,
356  shape1,
357  input1,
358  shape0,
359  output);
360 }

◆ DivisionBroadcast1ElementFloat16Test()

LayerTestResult<armnn::Half, 4> DivisionBroadcast1ElementFloat16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager 
)

Definition at line 200 of file DivisionTestImpl.cpp.

203 {
204  using namespace half_float::literal;
205 
206  unsigned int shape0[] = { 1, 2, 2, 2 };
207  unsigned int shape1[] = { 1, 1, 1, 1 };
208 
209  std::vector<armnn::Half> input0({ 2._h, 4._h, 6._h, 8._h, 10._h, 12._h, 14._h, 16._h});
210 
211  std::vector<armnn::Half> input1({ 2._h });
212 
213  std::vector<armnn::Half> output({ 1._h, 2._h, 3._h, 4._h, 5._h, 6._h, 7._h, 8._h});
214 
215  return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Float16>(
216  workloadFactory,
217  memoryManager,
218  shape0,
219  input0,
220  shape1,
221  input1,
222  shape0,
223  output);
224 }

◆ DivisionBroadcast1ElementInt16Test()

LayerTestResult<int16_t, 4> DivisionBroadcast1ElementInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager 
)

Definition at line 399 of file DivisionTestImpl.cpp.

402 {
403  unsigned int shape0[] = { 1, 2, 2, 2 };
404  unsigned int shape1[] = { 1, 1, 1, 1 };
405 
406  std::vector<int16_t> input0 = { 2, 4, 6, 8, 10, 12, 14, 16};
407 
408  std::vector<int16_t> input1 = { 2 };
409 
410  std::vector<int16_t> output = { 1, 2, 3, 4, 5, 6, 7, 8};
411 
412  return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::QSymmS16>(
413  workloadFactory,
414  memoryManager,
415  shape0,
416  input0,
417  shape1,
418  input1,
419  shape0,
420  output);
421 }

◆ DivisionBroadcast1ElementTest()

LayerTestResult<float, 4> DivisionBroadcast1ElementTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager 
)

Definition at line 100 of file DivisionTestImpl.cpp.

103 {
104  unsigned int shape0[] = { 1, 2, 2, 2 };
105  unsigned int shape1[] = { 1, 1, 1, 1 };
106 
107  std::vector<float> input0({ 2, 4, 6, 8, 10, 12, 14, 16});
108 
109  std::vector<float> input1({ 2 });
110 
111  std::vector<float> output({ 1, 2, 3, 4, 5, 6, 7, 8});
112 
113  return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Float32>(
114  workloadFactory,
115  memoryManager,
116  shape0,
117  input0,
118  shape1,
119  input1,
120  shape0,
121  output);
122 }

◆ DivisionBroadcast1ElementUint8Test()

LayerTestResult<uint8_t, 4> DivisionBroadcast1ElementUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager 
)

Definition at line 304 of file DivisionTestImpl.cpp.

307 {
308  unsigned int shape0[] = { 1, 2, 2, 2 };
309  unsigned int shape1[] = { 1, 1, 1, 1 };
310 
311  std::vector<uint8_t> input0 = { 2, 4, 6, 8, 10, 12, 14, 16};
312 
313  std::vector<uint8_t> input1 = { 2 };
314 
315  std::vector<uint8_t> output = { 1, 2, 3, 4, 5, 6, 7, 8};
316 
317  return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::QAsymmU8>(
318  workloadFactory,
319  memoryManager,
320  shape0,
321  input0,
322  shape1,
323  input1,
324  shape0,
325  output);
326 }

◆ DivisionByZeroTest()

LayerTestResult<float, 4> DivisionByZeroTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager 
)

Definition at line 19 of file DivisionTestImpl.cpp.

References armnn::IgnoreUnused().

22 {
23  IgnoreUnused(memoryManager);
24  const unsigned int width = 2u;
25  const unsigned int height = 2u;
26  const unsigned int channelCount = 2u;
27  const unsigned int batchSize = 2u;
28 
29  unsigned int shape[] = { batchSize, channelCount, height, width };
30 
31  std::vector<float> input0 =
32  {
33  1.f, 1.f, 1.f, 1.f, 0.f, 0.f, 0.f, 0.f,
34  -1.f, -1.f, -1.f, -1.f, 5.f, 5.f, 5.f, 5.f
35  };
36 
37  std::vector<float> input1 =
38  {
39  0.f, 0.f, -0.f, -0.f, 0.f, 0.f, -0.f, -0.f,
40  0.f, 0.f, -0.f, -0.f, 5.f, 5.f, 5.f, 5.f
41  };
42 
43  std::vector<float> output =
44  {
45  INFINITY, INFINITY, -INFINITY, -INFINITY, NAN, NAN, -NAN, -NAN,
46  -INFINITY, -INFINITY, INFINITY, INFINITY, 1, 1, 1, 1
47  };
48 
49  return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Float32>(
50  workloadFactory,
51  memoryManager,
52  shape,
53  input0,
54  shape,
55  input1,
56  shape,
57  output);
58 }
void IgnoreUnused(Ts &&...)

◆ DivisionFloat16Test()

LayerTestResult<armnn::Half, 4> DivisionFloat16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager 
)

Definition at line 158 of file DivisionTestImpl.cpp.

161 {
162  using namespace half_float::literal;
163 
164  const unsigned int width = 2u;
165  const unsigned int height = 2u;
166  const unsigned int channelCount = 2u;
167  const unsigned int batchSize = 2u;
168 
169  unsigned int shape[] = { batchSize, channelCount, height, width };
170 
171  std::vector<armnn::Half> input0 =
172  {
173  2._h, 2._h, 2._h, 2._h, 3._h, 3._h, 3._h, 3._h,
174  4._h, 4._h, 4._h, 4._h, 5._h, 5._h, 5._h, 5._h
175  };
176 
177  std::vector<armnn::Half> input1 =
178  {
179  1._h, 1._h, 1._h, 1._h, 2._h, 2._h, 2._h, 2._h,
180  4._h, 4._h, 4._h, 4._h, 4._h, 4._h, 4._h, 4._h
181  };
182 
183  std::vector<armnn::Half> output =
184  {
185  2._h, 2._h, 2._h, 2._h, 1.50_h, 1.50_h, 1.50_h, 1.50_h,
186  1._h, 1._h, 1._h, 1._h, 1.25_h, 1.25_h, 1.25_h, 1.25_h
187  };
188 
189  return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Float16>(
190  workloadFactory,
191  memoryManager,
192  shape,
193  input0,
194  shape,
195  input1,
196  shape,
197  output);
198 }

◆ DivisionInt16Test()

LayerTestResult<int16_t,4> DivisionInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager 
)

Definition at line 362 of file DivisionTestImpl.cpp.

365 {
366  unsigned int shape[] = { 2, 2, 2, 2 };
367 
368  std::vector<int16_t> input0 =
369  {
370  2, 2, 2, 2, 3, 3, 3, 3,
371  4, 4, 4, 4, 5, 5, 5, 5
372  };
373 
374  std::vector<int16_t> input1 =
375  {
376  1, 1, 1, 1, 2, 2, 2, 2,
377  4, 4, 4, 4, 4, 4, 4, 4
378  };
379 
380  std::vector<int16_t> output =
381  {
382  8, 8, 8, 8, 6, 6, 6, 6,
383  4, 4, 4, 4, 5, 5, 5, 5
384  };
385 
386  return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::QSymmS16>(
387  workloadFactory,
388  memoryManager,
389  shape,
390  input0,
391  shape,
392  input1,
393  shape,
394  output,
395  0.25f,
396  0);
397 }

◆ DivisionTest()

LayerTestResult<float, 4> DivisionTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager 
)

Definition at line 60 of file DivisionTestImpl.cpp.

63 {
64  const unsigned int width = 2u;
65  const unsigned int height = 2u;
66  const unsigned int channelCount = 2u;
67  const unsigned int batchSize = 2u;
68 
69  unsigned int shape[] = { batchSize, channelCount, height, width };
70 
71  std::vector<float> input0 =
72  {
73  2.f, 2.f, 2.f, 2.f, 3.f, 3.f, 3.f, 3.f,
74  4.f, 4.f, 4.f, 4.f, 5.f, 5.f, 5.f, 5.f
75  };
76 
77  std::vector<float> input1 =
78  {
79  1.f, 1.f, 1.f, 1.f, 2.f, 2.f, 2.f, 2.f,
80  4.f, 4.f, 4.f, 4.f, 4.f, 4.f, 4.f, 4.f
81  };
82 
83  std::vector<float> output =
84  {
85  2.f, 2.f, 2.f, 2.f, 1.50f, 1.50f, 1.50f, 1.50f,
86  1.f, 1.f, 1.f, 1.f, 1.25f, 1.25f, 1.25f, 1.25f
87  };
88 
89  return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Float32>(
90  workloadFactory,
91  memoryManager,
92  shape,
93  input0,
94  shape,
95  input1,
96  shape,
97  output);
98 }

◆ DivisionUint8Test()

LayerTestResult<uint8_t, 4> DivisionUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager 
)

Definition at line 262 of file DivisionTestImpl.cpp.

265 {
266  const unsigned int width = 2u;
267  const unsigned int height = 2u;
268  const unsigned int channelCount = 2u;
269  const unsigned int batchSize = 2u;
270 
271  unsigned int shape[] = { batchSize, channelCount, height, width };
272 
273  std::vector<uint8_t> input0 =
274  {
275  2, 2, 2, 2, 3, 3, 3, 3,
276  4, 4, 4, 4, 5, 5, 5, 5
277  };
278 
279  std::vector<uint8_t> input1 =
280  {
281  1, 1, 1, 1, 2, 2, 2, 2,
282  4, 4, 4, 4, 4, 4, 4, 4
283  };
284 
285  std::vector<uint8_t> output =
286  {
287  8, 8, 8, 8, 6, 6, 6, 6,
288  4, 4, 4, 4, 5, 5, 5, 5
289  };
290 
291  return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::QAsymmU8>(
292  workloadFactory,
293  memoryManager,
294  shape,
295  input0,
296  shape,
297  input1,
298  shape,
299  output,
300  0.25f,
301  0);
302 }