ArmNN
 21.02
PadTestImpl.cpp File Reference

Go to the source code of this file.

Functions

template<armnn::DataType ArmnnType, typename T >
LayerTestResult< T, 2 > Pad2dTestCommon (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory, float qScale, int32_t qOffset, const float customPaddingValue)
 
template<armnn::DataType ArmnnType, typename T >
LayerTestResult< T, 3 > Pad3dTestCommon (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory, float qScale, int32_t qOffset)
 
template<armnn::DataType ArmnnType, typename T >
LayerTestResult< T, 4 > Pad4dTestCommon (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory, float qScale, int32_t qOffset)
 
template<armnn::DataType ArmnnType, typename T >
LayerTestResult< T, 2 > PadQAsymmTestCommon (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory, float qScale, int32_t qOffset, const float customPaddingValue)
 
template LayerTestResult< armnn::ResolveType< armnn::DataType::QSymmS16 >, 2 > Pad2dTestCommon< armnn::DataType::QSymmS16 > (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory, float qScale, int32_t qOffset, const float customPaddingValue)
 
template LayerTestResult< armnn::ResolveType< armnn::DataType::QSymmS16 >, 3 > Pad3dTestCommon< armnn::DataType::QSymmS16 > (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory, float qScale, int32_t qOffset)
 
template LayerTestResult< armnn::ResolveType< armnn::DataType::QSymmS16 >, 4 > Pad4dTestCommon< armnn::DataType::QSymmS16 > (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory, float qScale, int32_t qOffset)
 
template LayerTestResult< armnn::ResolveType< armnn::DataType::QAsymmS8 >, 2 > PadQAsymmTestCommon< armnn::DataType::QAsymmS8 > (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory, float qScale, int32_t qOffset, const float customPaddingValue)
 
template LayerTestResult< armnn::ResolveType< armnn::DataType::QAsymmU8 >, 2 > PadQAsymmTestCommon< armnn::DataType::QAsymmU8 > (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory, float qScale, int32_t qOffset, const float customPaddingValue)
 
LayerTestResult< uint8_t, 2 > PadUint82dTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 2 > PadUint82dCustomPaddingTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 3 > PadUint83dTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 4 > PadUint84dTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 2 > PadFloat322dTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 2 > PadFloat322dCustomPaddingTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 3 > PadFloat323dTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 4 > PadFloat324dTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< armnn::BFloat16, 2 > PadBFloat162dTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< armnn::BFloat16, 2 > PadBFloat162dCustomPaddingTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< armnn::BFloat16, 3 > PadBFloat163dTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< armnn::BFloat16, 4 > PadBFloat164dTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int8_t, 2 > PadInt82dTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int8_t, 2 > PadInt82dCustomPaddingTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int8_t, 3 > PadInt83dTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int8_t, 4 > PadInt84dTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int8_t, 2 > PadInt8AsymmTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int8_t, 2 > PadInt8CustomPaddingAsymmTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 

Function Documentation

◆ Pad2dTestCommon()

LayerTestResult<T, 2> Pad2dTestCommon ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory,
float  qScale,
int32_t  qOffset,
const float  customPaddingValue 
)

Definition at line 20 of file PadTestImpl.cpp.

References CopyDataFromITensorHandle(), CopyDataToITensorHandle(), IWorkloadFactory::CreatePad(), ITensorHandleFactory::CreateTensorHandle(), armnn::IgnoreUnused(), PadDescriptor::m_PadList, PadDescriptor::m_PadValue, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, LayerTestResult< T, n >::output, and LayerTestResult< T, n >::outputExpected.

27 {
28  IgnoreUnused(memoryManager);
29  const armnn::TensorShape inputShape{ 3, 3 };
30  const armnn::TensorShape outputShape{ 7, 7 };
31 
32  const armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType, qScale, qOffset);
33  const armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType, qScale, qOffset);
34 
35  std::vector<T> inputValues = armnnUtils::QuantizedVector<T>(
36  {
37  // Height (3) x Width (3)
38  4, 8, 6,
39  7, 4, 4,
40  3, 2, 4
41  },
42  qScale, qOffset);
43 
44  auto p = customPaddingValue;
45  std::vector<T> expectedOutputValues = armnnUtils::QuantizedVector<T>(
46  {
47  p, p, p, p, p, p, p,
48  p, p, p, p, p, p, p,
49  p, p, 4, 8, 6, p, p,
50  p, p, 7, 4, 4, p, p,
51  p, p, 3, 2, 4, p, p,
52  p, p, p, p, p, p, p,
53  p, p, p, p, p, p, p
54  },
55  qScale, qOffset);
56 
57  auto inputTensor = MakeTensor<T, 2>(inputTensorInfo, std::vector<T>(inputValues));
58 
59  LayerTestResult<T, 2> result(outputTensorInfo);
60  result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, std::vector<T>(expectedOutputValues));
61 
62  std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo);
63  std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo);
64 
65 
66  armnn::PadQueueDescriptor descriptor;
67 
68  std::vector<std::pair<unsigned int, unsigned int>> padList;
69  padList.push_back(std::pair<unsigned int, unsigned int>(2,2));
70  padList.push_back(std::pair<unsigned int, unsigned int>(2,2));
71 
72  descriptor.m_Parameters.m_PadList = padList;
73  descriptor.m_Parameters.m_PadValue = customPaddingValue;
75 
76  AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
77  AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
78 
79  std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info);
80 
81  inputHandle->Allocate();
82  outputHandle->Allocate();
83 
84  CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0]);
85 
86  workload->PostAllocationConfigure();
87  workload->Execute();
88 
89  CopyDataFromITensorHandle(&result.output[0][0], outputHandle.get());
90 
91  return result;
92 }
float m_PadValue
Optional value to use for padding, defaults to 0.
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding for input dimension.
void IgnoreUnused(Ts &&...)
virtual std::unique_ptr< IWorkload > CreatePad(const PadQueueDescriptor &descriptor, const WorkloadInfo &Info) const
void CopyDataFromITensorHandle(void *memory, const armnn::ITensorHandle *tensorHandle)
Contains information about inputs and outputs to a layer.
virtual std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const =0
void CopyDataToITensorHandle(armnn::ITensorHandle *tensorHandle, const void *memory)

◆ Pad2dTestCommon< armnn::DataType::QSymmS16 >()

template LayerTestResult<armnn::ResolveType<armnn::DataType::QSymmS16>, 2> Pad2dTestCommon< armnn::DataType::QSymmS16 > ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory,
float  qScale,
int32_t  qOffset,
const float  customPaddingValue 
)

◆ Pad3dTestCommon()

LayerTestResult<T, 3> Pad3dTestCommon ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory,
float  qScale,
int32_t  qOffset 
)

Definition at line 95 of file PadTestImpl.cpp.

References CopyDataFromITensorHandle(), CopyDataToITensorHandle(), IWorkloadFactory::CreatePad(), ITensorHandleFactory::CreateTensorHandle(), armnn::IgnoreUnused(), PadDescriptor::m_PadList, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, LayerTestResult< T, n >::output, and LayerTestResult< T, n >::outputExpected.

101 {
102  IgnoreUnused(memoryManager);
103  const armnn::TensorShape inputShape{ 2, 2, 2 };
104  const armnn::TensorShape outputShape{ 3, 5, 6 };
105 
106  const armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType, qScale, qOffset);
107  const armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType, qScale, qOffset);
108 
109  std::vector<T> inputValues = armnnUtils::QuantizedVector<T>(
110  {
111  // Channel 0, Height (2) x Width (2)
112  0, 4,
113  2, 5,
114 
115  // Channel 1, Height (2) x Width (2)
116  6, 1,
117  5, 2
118  },
119  qScale, qOffset);
120 
121  std::vector<T> expectedOutputValues = armnnUtils::QuantizedVector<T>(
122  {
123  0, 0, 0, 0, 0, 0,
124  0, 0, 0, 0, 0, 0,
125  0, 0, 0, 4, 0, 0,
126  0, 0, 2, 5, 0, 0,
127  0, 0, 0, 0, 0, 0,
128 
129  0, 0, 0, 0, 0, 0,
130  0, 0, 0, 0, 0, 0,
131  0, 0, 6, 1, 0, 0,
132  0, 0, 5, 2, 0, 0,
133  0, 0, 0, 0, 0, 0,
134 
135  0, 0, 0, 0, 0, 0,
136  0, 0, 0, 0, 0, 0,
137  0, 0, 0, 0, 0, 0,
138  0, 0, 0, 0, 0, 0,
139  0, 0, 0, 0, 0, 0
140  },
141  qScale, qOffset);
142 
143  auto inputTensor = MakeTensor<T, 3>(inputTensorInfo, std::vector<T>(inputValues));
144 
145  LayerTestResult<T, 3> result(outputTensorInfo);
146  result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, std::vector<T>(expectedOutputValues));
147 
148  std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo);
149  std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo);
150 
151 
152  armnn::PadQueueDescriptor descriptor;
153 
154  std::vector<std::pair<unsigned int, unsigned int>> PadList;
155  PadList.push_back(std::pair<unsigned int, unsigned int>(0,1));
156  PadList.push_back(std::pair<unsigned int, unsigned int>(2,1));
157  PadList.push_back(std::pair<unsigned int, unsigned int>(2,2));
158 
159  descriptor.m_Parameters.m_PadList = PadList;
161 
162  AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
163  AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
164 
165  std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info);
166 
167  inputHandle->Allocate();
168  outputHandle->Allocate();
169 
170  CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0][0]);
171 
172  workload->PostAllocationConfigure();
173  workload->Execute();
174 
175  CopyDataFromITensorHandle(&result.output[0][0][0], outputHandle.get());
176 
177  return result;
178 }
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding for input dimension.
void IgnoreUnused(Ts &&...)
virtual std::unique_ptr< IWorkload > CreatePad(const PadQueueDescriptor &descriptor, const WorkloadInfo &Info) const
void CopyDataFromITensorHandle(void *memory, const armnn::ITensorHandle *tensorHandle)
Contains information about inputs and outputs to a layer.
virtual std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const =0
void CopyDataToITensorHandle(armnn::ITensorHandle *tensorHandle, const void *memory)

◆ Pad3dTestCommon< armnn::DataType::QSymmS16 >()

template LayerTestResult<armnn::ResolveType<armnn::DataType::QSymmS16>, 3> Pad3dTestCommon< armnn::DataType::QSymmS16 > ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory,
float  qScale,
int32_t  qOffset 
)

◆ Pad4dTestCommon()

LayerTestResult<T, 4> Pad4dTestCommon ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory,
float  qScale,
int32_t  qOffset 
)

Definition at line 181 of file PadTestImpl.cpp.

References CopyDataFromITensorHandle(), CopyDataToITensorHandle(), IWorkloadFactory::CreatePad(), ITensorHandleFactory::CreateTensorHandle(), armnn::IgnoreUnused(), PadDescriptor::m_PadList, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, LayerTestResult< T, n >::output, and LayerTestResult< T, n >::outputExpected.

187 {
188  IgnoreUnused(memoryManager);
189  const armnn::TensorShape inputShape{ 2, 2, 3, 2 };
190  const armnn::TensorShape outputShape{ 4, 5, 7, 4 };
191 
192  const armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType, qScale, qOffset);
193  const armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType, qScale, qOffset);
194 
195  std::vector<T> inputValues = armnnUtils::QuantizedVector<T>(
196  {
197  // Batch 0, Channel 0, Height (3) x Width (2)
198  0, 1,
199  2, 3,
200  4, 5,
201 
202  // Batch 0, Channel 1, Height (3) x Width (2)
203  6, 7,
204  8, 9,
205  10, 11,
206 
207  // Batch 1, Channel 0, Height (3) x Width (2)
208  12, 13,
209  14, 15,
210  16, 17,
211 
212  // Batch 1, Channel 1, Height (3) x Width (2)
213  18, 19,
214  20, 21,
215  22, 23
216  },
217  qScale, qOffset);
218 
219  std::vector<T> expectedOutputValues = armnnUtils::QuantizedVector<T>(
220  {
221  0, 0, 0, 0,
222  0, 0, 0, 0,
223  0, 0, 0, 0,
224  0, 0, 0, 0,
225  0, 0, 0, 0,
226  0, 0, 0, 0,
227  0, 0, 0, 0,
228 
229  0, 0, 0, 0,
230  0, 0, 0, 0,
231  0, 0, 0, 0,
232  0, 0, 0, 0,
233  0, 0, 0, 0,
234  0, 0, 0, 0,
235  0, 0, 0, 0,
236 
237  0, 0, 0, 0,
238  0, 0, 0, 0,
239  0, 0, 0, 0,
240  0, 0, 0, 0,
241  0, 0, 0, 0,
242  0, 0, 0, 0,
243  0, 0, 0, 0,
244 
245  0, 0, 0, 0,
246  0, 0, 0, 0,
247  0, 0, 0, 0,
248  0, 0, 0, 0,
249  0, 0, 0, 0,
250  0, 0, 0, 0,
251  0, 0, 0, 0,
252 
253  0, 0, 0, 0,
254  0, 0, 0, 0,
255  0, 0, 0, 0,
256  0, 0, 0, 0,
257  0, 0, 0, 0,
258  0, 0, 0, 0,
259  0, 0, 0, 0,
260 
261  0, 0, 0, 0,
262  0, 0, 0, 0,
263  0, 0, 0, 0,
264  0, 0, 0, 0,
265  0, 0, 0, 0,
266  0, 0, 0, 0,
267  0, 0, 0, 0,
268 
269  0, 0, 0, 0,
270  0, 0, 0, 0,
271  0, 0, 0, 0,
272  0, 0, 0, 0,
273  0, 0, 0, 0,
274  0, 0, 0, 0,
275  0, 0, 0, 0,
276 
277  0, 0, 0, 0,
278  0, 0, 0, 0,
279  0, 0, 0, 0,
280  0, 0, 1, 0,
281  0, 2, 3, 0,
282  0, 4, 5, 0,
283  0, 0, 0, 0,
284 
285  0, 0, 0, 0,
286  0, 0, 0, 0,
287  0, 0, 0, 0,
288  0, 6, 7, 0,
289  0, 8, 9, 0,
290  0, 10, 11, 0,
291  0, 0, 0, 0,
292 
293  0, 0, 0, 0,
294  0, 0, 0, 0,
295  0, 0, 0, 0,
296  0, 0, 0, 0,
297  0, 0, 0, 0,
298  0, 0, 0, 0,
299  0, 0, 0, 0,
300 
301  0, 0, 0, 0,
302  0, 0, 0, 0,
303  0, 0, 0, 0,
304  0, 0, 0, 0,
305  0, 0, 0, 0,
306  0, 0, 0, 0,
307  0, 0, 0, 0,
308 
309  0, 0, 0, 0,
310  0, 0, 0, 0,
311  0, 0, 0, 0,
312  0, 0, 0, 0,
313  0, 0, 0, 0,
314  0, 0, 0, 0,
315  0, 0, 0, 0,
316 
317  0, 0, 0, 0,
318  0, 0, 0, 0,
319  0, 0, 0, 0,
320  0, 12, 13, 0,
321  0, 14, 15, 0,
322  0, 16, 17, 0,
323  0, 0, 0, 0,
324 
325  0, 0, 0, 0,
326  0, 0, 0, 0,
327  0, 0, 0, 0,
328  0, 18, 19, 0,
329  0, 20, 21, 0,
330  0, 22, 23, 0,
331  0, 0, 0, 0,
332 
333  0, 0, 0, 0,
334  0, 0, 0, 0,
335  0, 0, 0, 0,
336  0, 0, 0, 0,
337  0, 0, 0, 0,
338  0, 0, 0, 0,
339  0, 0, 0, 0,
340 
341  0, 0, 0, 0,
342  0, 0, 0, 0,
343  0, 0, 0, 0,
344  0, 0, 0, 0,
345  0, 0, 0, 0,
346  0, 0, 0, 0,
347  0, 0, 0, 0,
348 
349  0, 0, 0, 0,
350  0, 0, 0, 0,
351  0, 0, 0, 0,
352  0, 0, 0, 0,
353  0, 0, 0, 0,
354  0, 0, 0, 0,
355  0, 0, 0, 0,
356 
357  0, 0, 0, 0,
358  0, 0, 0, 0,
359  0, 0, 0, 0,
360  0, 0, 0, 0,
361  0, 0, 0, 0,
362  0, 0, 0, 0,
363  0, 0, 0, 0,
364 
365  0, 0, 0, 0,
366  0, 0, 0, 0,
367  0, 0, 0, 0,
368  0, 0, 0, 0,
369  0, 0, 0, 0,
370  0, 0, 0, 0,
371  0, 0, 0, 0,
372 
373  0, 0, 0, 0,
374  0, 0, 0, 0,
375  0, 0, 0, 0,
376  0, 0, 0, 0,
377  0, 0, 0, 0,
378  0, 0, 0, 0,
379  0, 0, 0, 0
380  },
381  qScale, qOffset);
382 
383  auto inputTensor = MakeTensor<T, 4>(inputTensorInfo, std::vector<T>(inputValues));
384 
385  LayerTestResult<T, 4> result(outputTensorInfo);
386  result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, std::vector<T>(expectedOutputValues));
387 
388  std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo);
389  std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo);
390 
391  armnn::PadQueueDescriptor descriptor;
392 
393  std::vector<std::pair<unsigned int, unsigned int>> PadList;
394  PadList.push_back(std::pair<unsigned int, unsigned int>(1,1));
395  PadList.push_back(std::pair<unsigned int, unsigned int>(2,1));
396  PadList.push_back(std::pair<unsigned int, unsigned int>(3,1));
397  PadList.push_back(std::pair<unsigned int, unsigned int>(1,1));
398 
399  descriptor.m_Parameters.m_PadList = PadList;
401 
402  AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
403  AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
404 
405  std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info);
406 
407  inputHandle->Allocate();
408  outputHandle->Allocate();
409 
410  CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0][0][0]);
411 
412  workload->PostAllocationConfigure();
413  workload->Execute();
414 
415  CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
416 
417  return result;
418 }
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding for input dimension.
void IgnoreUnused(Ts &&...)
virtual std::unique_ptr< IWorkload > CreatePad(const PadQueueDescriptor &descriptor, const WorkloadInfo &Info) const
void CopyDataFromITensorHandle(void *memory, const armnn::ITensorHandle *tensorHandle)
Contains information about inputs and outputs to a layer.
virtual std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const =0
void CopyDataToITensorHandle(armnn::ITensorHandle *tensorHandle, const void *memory)

◆ Pad4dTestCommon< armnn::DataType::QSymmS16 >()

template LayerTestResult<armnn::ResolveType<armnn::DataType::QSymmS16>, 4> Pad4dTestCommon< armnn::DataType::QSymmS16 > ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory,
float  qScale,
int32_t  qOffset 
)

◆ PadBFloat162dCustomPaddingTest()

LayerTestResult<armnn::BFloat16, 2> PadBFloat162dCustomPaddingTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 618 of file PadTestImpl.cpp.

622 {
623  return Pad2dTestCommon<armnn::DataType::BFloat16>(
624  workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0, 1.0f);
625 }

◆ PadBFloat162dTest()

LayerTestResult<armnn::BFloat16, 2> PadBFloat162dTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 610 of file PadTestImpl.cpp.

614 {
615  return Pad2dTestCommon<armnn::DataType::BFloat16>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0);
616 }

◆ PadBFloat163dTest()

LayerTestResult<armnn::BFloat16, 3> PadBFloat163dTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 627 of file PadTestImpl.cpp.

631 {
632  return Pad3dTestCommon<armnn::DataType::BFloat16>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0);
633 }

◆ PadBFloat164dTest()

LayerTestResult<armnn::BFloat16, 4> PadBFloat164dTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 635 of file PadTestImpl.cpp.

639 {
640  return Pad4dTestCommon<armnn::DataType::BFloat16>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0);
641 }

◆ PadFloat322dCustomPaddingTest()

LayerTestResult<float, 2> PadFloat322dCustomPaddingTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 585 of file PadTestImpl.cpp.

589 {
590  return Pad2dTestCommon<armnn::DataType::Float32>(
591  workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0, 1.0f);
592 }

◆ PadFloat322dTest()

LayerTestResult<float, 2> PadFloat322dTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 577 of file PadTestImpl.cpp.

581 {
582  return Pad2dTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0);
583 }

◆ PadFloat323dTest()

LayerTestResult<float, 3> PadFloat323dTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 594 of file PadTestImpl.cpp.

598 {
599  return Pad3dTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0);
600 }

◆ PadFloat324dTest()

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

Definition at line 602 of file PadTestImpl.cpp.

606 {
607  return Pad4dTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0);
608 }

◆ PadInt82dCustomPaddingTest()

LayerTestResult<int8_t, 2> PadInt82dCustomPaddingTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 652 of file PadTestImpl.cpp.

656 {
657  return Pad2dTestCommon<armnn::DataType::QSymmS8>(
658  workloadFactory, memoryManager, tensorHandleFactory, 1.0f, 0, 1.0f);
659 }

◆ PadInt82dTest()

LayerTestResult<int8_t, 2> PadInt82dTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 643 of file PadTestImpl.cpp.

647 {
648  return Pad2dTestCommon<armnn::DataType::QSymmS8>(
649  workloadFactory, memoryManager, tensorHandleFactory, 1.0f, 0);
650 }

◆ PadInt83dTest()

LayerTestResult<int8_t, 3> PadInt83dTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 661 of file PadTestImpl.cpp.

665 {
666  return Pad3dTestCommon<armnn::DataType::QSymmS8>(workloadFactory, memoryManager, tensorHandleFactory, 1.0f, 0);
667 }

◆ PadInt84dTest()

LayerTestResult<int8_t, 4> PadInt84dTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 669 of file PadTestImpl.cpp.

673 {
674  return Pad4dTestCommon<armnn::DataType::QSymmS8>(workloadFactory, memoryManager, tensorHandleFactory, 1.0f, 0);
675 }

◆ PadInt8AsymmTest()

LayerTestResult<int8_t, 2> PadInt8AsymmTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 677 of file PadTestImpl.cpp.

681 {
682  return PadQAsymmTestCommon<armnn::DataType::QAsymmS8>(
683  workloadFactory, memoryManager, tensorHandleFactory, 2.0f, 2);
684 }

◆ PadInt8CustomPaddingAsymmTest()

LayerTestResult<int8_t, 2> PadInt8CustomPaddingAsymmTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 686 of file PadTestImpl.cpp.

690 {
691  return PadQAsymmTestCommon<armnn::DataType::QAsymmS8>(
692  workloadFactory, memoryManager, tensorHandleFactory, 2.0f, 3, 1.0f);
693 }

◆ PadQAsymmTestCommon()

LayerTestResult<T, 2> PadQAsymmTestCommon ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory,
float  qScale,
int32_t  qOffset,
const float  customPaddingValue 
)

Definition at line 421 of file PadTestImpl.cpp.

References CopyDataFromITensorHandle(), CopyDataToITensorHandle(), IWorkloadFactory::CreatePad(), ITensorHandleFactory::CreateTensorHandle(), armnn::IgnoreUnused(), PadDescriptor::m_PadList, PadDescriptor::m_PadValue, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, LayerTestResult< T, n >::output, and LayerTestResult< T, n >::outputExpected.

428 {
429  IgnoreUnused(memoryManager);
430  const armnn::TensorShape inputShape{ 3, 3 };
431  const armnn::TensorShape outputShape{ 7, 7 };
432 
433  const armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType, qScale, qOffset);
434  const armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType, qScale, qOffset);
435 
436  std::vector<T> inputValues =
437  {
438  // Height (3) x Width (3)
439  4, 8, 6,
440  7, 4, 4,
441  3, 2, 4
442  };
443 
444  T p = static_cast<T>(customPaddingValue);
445  std::vector<T> expectedOutputValues =
446  {
447  p, p, p, p, p, p, p,
448  p, p, p, p, p, p, p,
449  p, p, 4, 8, 6, p, p,
450  p, p, 7, 4, 4, p, p,
451  p, p, 3, 2, 4, p, p,
452  p, p, p, p, p, p, p,
453  p, p, p, p, p, p, p
454  };
455 
456  auto inputTensor = MakeTensor<T, 2>(inputTensorInfo, std::vector<T>(inputValues));
457 
458  LayerTestResult<T, 2> result(outputTensorInfo);
459  result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, std::vector<T>(expectedOutputValues));
460 
461  std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo);
462  std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo);
463 
464 
465  armnn::PadQueueDescriptor descriptor;
466 
467  std::vector<std::pair<unsigned int, unsigned int>> padList;
468  padList.push_back(std::pair<unsigned int, unsigned int>(2,2));
469  padList.push_back(std::pair<unsigned int, unsigned int>(2,2));
470 
471  descriptor.m_Parameters.m_PadList = padList;
472  descriptor.m_Parameters.m_PadValue = customPaddingValue;
474 
475  AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
476  AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
477 
478  std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info);
479 
480  inputHandle->Allocate();
481  outputHandle->Allocate();
482 
483  CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0]);
484 
485  workload->PostAllocationConfigure();
486  workload->Execute();
487 
488  CopyDataFromITensorHandle(&result.output[0][0], outputHandle.get());
489 
490  return result;
491 }
float m_PadValue
Optional value to use for padding, defaults to 0.
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding for input dimension.
void IgnoreUnused(Ts &&...)
virtual std::unique_ptr< IWorkload > CreatePad(const PadQueueDescriptor &descriptor, const WorkloadInfo &Info) const
void CopyDataFromITensorHandle(void *memory, const armnn::ITensorHandle *tensorHandle)
Contains information about inputs and outputs to a layer.
virtual std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const =0
void CopyDataToITensorHandle(armnn::ITensorHandle *tensorHandle, const void *memory)

◆ PadQAsymmTestCommon< armnn::DataType::QAsymmS8 >()

template LayerTestResult<armnn::ResolveType<armnn::DataType::QAsymmS8>, 2> PadQAsymmTestCommon< armnn::DataType::QAsymmS8 > ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory,
float  qScale,
int32_t  qOffset,
const float  customPaddingValue 
)

◆ PadQAsymmTestCommon< armnn::DataType::QAsymmU8 >()

template LayerTestResult<armnn::ResolveType<armnn::DataType::QAsymmU8>, 2> PadQAsymmTestCommon< armnn::DataType::QAsymmU8 > ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory,
float  qScale,
int32_t  qOffset,
const float  customPaddingValue 
)

◆ PadUint82dCustomPaddingTest()

LayerTestResult<uint8_t, 2> PadUint82dCustomPaddingTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 552 of file PadTestImpl.cpp.

556 {
557  return Pad2dTestCommon<armnn::DataType::QAsymmU8>(
558  workloadFactory, memoryManager, tensorHandleFactory, 1.0f, 0, 1.0f);
559 }

◆ PadUint82dTest()

LayerTestResult<uint8_t, 2> PadUint82dTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 544 of file PadTestImpl.cpp.

548 {
549  return Pad2dTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 1.0f, 0);
550 }

◆ PadUint83dTest()

LayerTestResult<uint8_t, 3> PadUint83dTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 561 of file PadTestImpl.cpp.

565 {
566  return Pad3dTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 1.0f, 0);
567 }

◆ PadUint84dTest()

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

Definition at line 569 of file PadTestImpl.cpp.

573 {
574  return Pad4dTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 1.0f, 0);
575 }