ArmNN
 21.02
SubtractionTestImpl.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
9 
10 template<>
11 std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::SubtractionQueueDescriptor>(
12  const armnn::IWorkloadFactory& workloadFactory,
13  const armnn::WorkloadInfo& info,
14  const armnn::SubtractionQueueDescriptor& descriptor)
15 {
16  return workloadFactory.CreateSubtraction(descriptor, info);
17 }
18 
20  armnn::IWorkloadFactory& workloadFactory,
22  const armnn::ITensorHandleFactory& tensorHandleFactory)
23 {
24  const unsigned int shape0[] = { 1, 1, 2, 2 };
25  const unsigned int shape1[] = { 1, 1, 2, 2 };
26 
27  std::vector<uint8_t> input0 = { 10, 12, 14, 16 };
28  std::vector<uint8_t> input1 = { 1, 2, 1, 2 };
29  std::vector<uint8_t> output = { 3, 3, 5, 5 };
30 
31  return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::QAsymmU8>(
32  workloadFactory,
33  memoryManager,
34  shape0,
35  input0,
36  0.5f,
37  2,
38  shape1,
39  input1,
40  1.0f,
41  0,
42  shape0,
43  output,
44  tensorHandleFactory,
45  1.0f,
46  0);
47 }
48 
50  armnn::IWorkloadFactory& workloadFactory,
52  const armnn::ITensorHandleFactory& tensorHandleFactory)
53 {
54  const unsigned int shape0[] = { 1, 1, 2, 2 };
55  const unsigned int shape1[] = { 1, 1, 1, 1 };
56 
57  std::vector<uint8_t> input0 = { 10, 12, 14, 16 };
58 
59  std::vector<uint8_t> input1 = { 2 };
60 
61  std::vector<uint8_t> output = { 5, 6, 7, 8 };
62 
63  return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::QAsymmU8>(
64  workloadFactory,
65  memoryManager,
66  shape0,
67  input0,
68  0.5f,
69  2,
70  shape1,
71  input1,
72  1.0f,
73  0,
74  shape0,
75  output,
76  tensorHandleFactory,
77  1.0f,
78  3);
79 }
80 
82  armnn::IWorkloadFactory& workloadFactory,
84  const armnn::ITensorHandleFactory& tensorHandleFactory)
85 {
86  const unsigned int shape0[] = { 1, 1, 2, 2 };
87  const unsigned int shape1[] = { 1, 1, 2, 1 };
88 
89  std::vector<uint8_t> input0 = { 10, 12, 14, 16 };
90 
91  std::vector<uint8_t> input1 = { 2, 1 };
92 
93  std::vector<uint8_t> output = { 8, 11, 12, 15 };
94 
95  return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::QAsymmU8>(
96  workloadFactory,
97  memoryManager,
98  shape0,
99  input0,
100  shape1,
101  input1,
102  shape0,
103  output,
104  tensorHandleFactory);
105 }
106 
108  armnn::IWorkloadFactory& workloadFactory,
110  const armnn::ITensorHandleFactory& tensorHandleFactory)
111 {
112  const unsigned int shape0[] = { 1, 1, 2, 2 };
113  const unsigned int shape1[] = { 1, 1, 2, 2 };
114 
115  std::vector<float> input0 = { 1, 2, 3, 4 };
116  std::vector<float> input1 = { 1, -1, 0, 2 };
117  std::vector<float> output = { 0, 3, 3, 2 };
118 
119  return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Float32>(
120  workloadFactory,
121  memoryManager,
122  shape0,
123  input0,
124  shape1,
125  input1,
126  shape0,
127  output,
128  tensorHandleFactory);
129 }
130 
132  armnn::IWorkloadFactory& workloadFactory,
134  const armnn::ITensorHandleFactory& tensorHandleFactory)
135 {
136  const unsigned int shape0[] = { 1, 1, 2, 2 };
137  const unsigned int shape1[] = { 1, 1, 1, 1 };
138 
139  std::vector<float> input0 = { 1, 2, 3, 4 };
140 
141  std::vector<float> input1 = { 10 };
142 
143  std::vector<float> output = { -9, -8, -7, -6 };
144 
145  return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Float32>(
146  workloadFactory,
147  memoryManager,
148  shape0,
149  input0,
150  shape1,
151  input1,
152  shape0,
153  output,
154  tensorHandleFactory);
155 }
156 
158  armnn::IWorkloadFactory& workloadFactory,
160  const armnn::ITensorHandleFactory& tensorHandleFactory)
161 {
162  const unsigned int shape0[] = { 1, 1, 2, 2 };
163  const unsigned int shape1[] = { 1, 1, 1, 2 };
164 
165  std::vector<float> input0 = { 1, 2, 3, 4 };
166 
167  std::vector<float> input1 = { 10, -5 };
168 
169  std::vector<float> output = { -9, 7, -7, 9 };
170 
171  return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Float32>(
172  workloadFactory,
173  memoryManager,
174  shape0,
175  input0,
176  shape1,
177  input1,
178  shape0,
179  output,
180  tensorHandleFactory);
181 }
182 
184  armnn::IWorkloadFactory& workloadFactory,
186  const armnn::ITensorHandleFactory& tensorHandleFactory)
187 {
188  using namespace half_float::literal;
189 
190  const unsigned int shape0[] = { 1, 1, 2, 2 };
191  const unsigned int shape1[] = { 1, 1, 2, 2 };
192 
193  std::vector<armnn::Half> input0 = { 1._h, 2._h, 3._h, 4._h };
194  std::vector<armnn::Half> input1 = { 1._h, -1._h, 0._h, 2._h };
195  std::vector<armnn::Half> output = { 0._h, 3._h, 3._h, 2._h };
196 
197  return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Float16>(
198  workloadFactory,
199  memoryManager,
200  shape0,
201  input0,
202  shape1,
203  input1,
204  shape0,
205  output,
206  tensorHandleFactory);
207 }
208 
210  armnn::IWorkloadFactory& workloadFactory,
212  const armnn::ITensorHandleFactory& tensorHandleFactory)
213 {
214  using namespace half_float::literal;
215 
216  const unsigned int shape0[] = { 1, 1, 2, 2 };
217  const unsigned int shape1[] = { 1, 1, 1, 1 };
218 
219  std::vector<armnn::Half> input0 = { 1._h, 2._h, 3._h, 4._h };
220 
221  std::vector<armnn::Half> input1 = { 10._h };
222 
223  std::vector<armnn::Half> output = { -9._h, -8._h, -7._h, -6._h };
224 
225  return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Float16>(
226  workloadFactory,
227  memoryManager,
228  shape0,
229  input0,
230  shape1,
231  input1,
232  shape0,
233  output,
234  tensorHandleFactory);
235 }
236 
238  armnn::IWorkloadFactory& workloadFactory,
240  const armnn::ITensorHandleFactory& tensorHandleFactory)
241 {
242  using namespace half_float::literal;
243 
244  const unsigned int shape0[] = { 1, 1, 2, 2 };
245  const unsigned int shape1[] = { 1, 1, 1, 2 };
246 
247  std::vector<armnn::Half> input0 = { 1._h, 2._h, 3._h, 4._h };
248 
249  std::vector<armnn::Half> input1 = { 10._h, -5._h };
250 
251  std::vector<armnn::Half> output = { -9._h, 7._h, -7._h, 9._h };
252 
253  return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Float16>(
254  workloadFactory,
255  memoryManager,
256  shape0,
257  input0,
258  shape1,
259  input1,
260  shape0,
261  output,
262  tensorHandleFactory);
263 }
264 
266  armnn::IWorkloadFactory& workloadFactory,
268  const armnn::ITensorHandleFactory& tensorHandleFactory)
269 {
270  const unsigned int shape[] = { 1, 1, 2, 2 };
271 
272  std::vector<int16_t> input0 = { 10, 12, 14, 16 };
273  std::vector<int16_t> input1 = { 1, 2, 1, 2 };
274  std::vector<int16_t> output = { 3, 3, 5, 5 };
275 
276  return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::QSymmS16>(
277  workloadFactory,
278  memoryManager,
279  shape,
280  input0,
281  0.5f,
282  0,
283  shape,
284  input1,
285  1.0f,
286  0,
287  shape,
288  output,
289  tensorHandleFactory,
290  1.0f,
291  0);
292 }
293 
295  armnn::IWorkloadFactory& workloadFactory,
297  const armnn::ITensorHandleFactory& tensorHandleFactory)
298 {
299  const unsigned int shape0[] = { 1, 1, 2, 2 };
300  const unsigned int shape1[] = { 1, 1, 1, 1 };
301 
302  std::vector<int16_t> input0 = { 10, 12, 14, 16 };
303 
304  std::vector<int16_t> input1 = { 2 };
305 
306  std::vector<int16_t> output = { 3, 4, 5, 6 };
307 
308  return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::QSymmS16>(
309  workloadFactory,
310  memoryManager,
311  shape0,
312  input0,
313  0.5f,
314  0,
315  shape1,
316  input1,
317  1.0f,
318  0,
319  shape0,
320  output,
321  tensorHandleFactory,
322  1.0f,
323  0);
324 }
325 
327  armnn::IWorkloadFactory& workloadFactory,
329  const armnn::ITensorHandleFactory& tensorHandleFactory)
330 {
331  const unsigned int shape0[] = { 1, 1, 2, 2 };
332  const unsigned int shape1[] = { 1, 1, 2, 1 };
333 
334  std::vector<int16_t> input0 = { 10, 12, 14, 16 };
335 
336  std::vector<int16_t> input1 = { 2, 1 };
337 
338  std::vector<int16_t> output = { 8, 11, 12, 15 };
339 
340  return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::QSymmS16>(
341  workloadFactory,
342  memoryManager,
343  shape0,
344  input0,
345  shape1,
346  input1,
347  shape0,
348  output,
349  tensorHandleFactory);
350 }
351 
353  armnn::IWorkloadFactory& workloadFactory,
355  const armnn::ITensorHandleFactory& tensorHandleFactory)
356 {
357  const unsigned int shape[] = { 1, 1, 2, 2 };
358 
359  std::vector<int32_t> input0 = { 5, 6, 7, 8 };
360  std::vector<int32_t> input1 = { 1, 2, 1, 2 };
361  std::vector<int32_t> output = { 4, 4, 6, 6 };
362 
363  return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Signed32>(
364  workloadFactory,
365  memoryManager,
366  shape,
367  input0,
368  1.0f,
369  0,
370  shape,
371  input1,
372  1.0f,
373  0,
374  shape,
375  output,
376  tensorHandleFactory,
377  1.0f,
378  0);
379 }
380 
382  armnn::IWorkloadFactory& workloadFactory,
384  const armnn::ITensorHandleFactory& tensorHandleFactory)
385 {
386  const unsigned int shape0[] = { 1, 1, 2, 2 };
387  const unsigned int shape1[] = { 1, 1, 1, 1 };
388 
389  std::vector<int32_t> input0 = { 5, 6, 7, 8 };
390 
391  std::vector<int32_t> input1 = { 2 };
392 
393  std::vector<int32_t> output = { 3, 4, 5, 6 };
394 
395  return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Signed32>(
396  workloadFactory,
397  memoryManager,
398  shape0,
399  input0,
400  1.0f,
401  0,
402  shape1,
403  input1,
404  1.0f,
405  0,
406  shape0,
407  output,
408  tensorHandleFactory,
409  1.0f,
410  0);
411 }
412 
414  armnn::IWorkloadFactory& workloadFactory,
416  const armnn::ITensorHandleFactory& tensorHandleFactory)
417 {
418  const unsigned int shape0[] = { 1, 1, 2, 2 };
419  const unsigned int shape1[] = { 1, 1, 2, 1 };
420 
421  std::vector<int32_t> input0 = { 10, 12, 14, 16 };
422 
423  std::vector<int32_t> input1 = { 2, 1 };
424 
425  std::vector<int32_t> output = { 8, 11, 12, 15 };
426 
427  return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Signed32>(
428  workloadFactory,
429  memoryManager,
430  shape0,
431  input0,
432  shape1,
433  input1,
434  shape0,
435  output,
436  tensorHandleFactory);
437 }
LayerTestResult< armnn::Half, 4 > SubtractionBroadcast1ElementFloat16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< int16_t, 4 > SubtractionBroadcastInt16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< float, 4 > SubtractionBroadcast1ElementTest(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< uint8_t, 4 > SubtractionBroadcastUint8Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< armnn::Half, 4 > SubtractionFloat16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< int32_t, 4 > SubtractionInt32Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< int32_t, 4 > SubtractionBroadcastInt32Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
LayerTestResult< int32_t, 4 > SubtractionBroadcast1ElementInt32Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< float, 4 > SubtractionBroadcastTest(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< uint8_t, 4 > SubtractionUint8Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< int16_t, 4 > SubtractionBroadcast1ElementInt16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< float, 4 > SubtractionTest(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< uint8_t, 4 > SubtractionBroadcast1ElementUint8Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< armnn::Half, 4 > SubtractionBroadcastFloat16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< int16_t, 4 > SubtractionInt16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
Contains information about inputs and outputs to a layer.