ArmNN
 21.11
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(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), armnn::IgnoreUnused(), PadDescriptor::m_PadList, PadDescriptor::m_PadValue, and QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters.

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  std::vector<T> actualOutput(outputTensorInfo.GetNumElements());
58 
59  std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo);
60  std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo);
61 
62  armnn::PadQueueDescriptor descriptor;
63 
64  std::vector<std::pair<unsigned int, unsigned int>> padList;
65  padList.push_back(std::pair<unsigned int, unsigned int>(2,2));
66  padList.push_back(std::pair<unsigned int, unsigned int>(2,2));
67 
68  descriptor.m_Parameters.m_PadList = padList;
69  descriptor.m_Parameters.m_PadValue = customPaddingValue;
71 
72  AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
73  AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
74 
75  std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info);
76 
77  inputHandle->Allocate();
78  outputHandle->Allocate();
79 
80  CopyDataToITensorHandle(inputHandle.get(), inputValues.data());
81 
82  workload->PostAllocationConfigure();
83  workload->Execute();
84 
85  CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get());
86 
87  return LayerTestResult<T, 2>(actualOutput,
88  expectedOutputValues,
89  outputHandle->GetShape(),
90  outputTensorInfo.GetShape());
91 }
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 TensorInfos of 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 94 of file PadTestImpl.cpp.

References CopyDataFromITensorHandle(), CopyDataToITensorHandle(), IWorkloadFactory::CreatePad(), ITensorHandleFactory::CreateTensorHandle(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), armnn::IgnoreUnused(), PadDescriptor::m_PadList, and QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters.

100 {
101  IgnoreUnused(memoryManager);
102  const armnn::TensorShape inputShape{ 2, 2, 2 };
103  const armnn::TensorShape outputShape{ 3, 5, 6 };
104 
105  const armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType, qScale, qOffset);
106  const armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType, qScale, qOffset);
107 
108  std::vector<T> inputValues = armnnUtils::QuantizedVector<T>(
109  {
110  // Channel 0, Height (2) x Width (2)
111  0, 4,
112  2, 5,
113 
114  // Channel 1, Height (2) x Width (2)
115  6, 1,
116  5, 2
117  },
118  qScale, qOffset);
119 
120  std::vector<T> expectedOutputValues = armnnUtils::QuantizedVector<T>(
121  {
122  0, 0, 0, 0, 0, 0,
123  0, 0, 0, 0, 0, 0,
124  0, 0, 0, 4, 0, 0,
125  0, 0, 2, 5, 0, 0,
126  0, 0, 0, 0, 0, 0,
127 
128  0, 0, 0, 0, 0, 0,
129  0, 0, 0, 0, 0, 0,
130  0, 0, 6, 1, 0, 0,
131  0, 0, 5, 2, 0, 0,
132  0, 0, 0, 0, 0, 0,
133 
134  0, 0, 0, 0, 0, 0,
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  },
140  qScale, qOffset);
141 
142  std::vector<T> actualOutput(outputTensorInfo.GetNumElements());
143 
144  std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo);
145  std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo);
146 
147  armnn::PadQueueDescriptor descriptor;
148 
149  std::vector<std::pair<unsigned int, unsigned int>> PadList;
150  PadList.push_back(std::pair<unsigned int, unsigned int>(0,1));
151  PadList.push_back(std::pair<unsigned int, unsigned int>(2,1));
152  PadList.push_back(std::pair<unsigned int, unsigned int>(2,2));
153 
154  descriptor.m_Parameters.m_PadList = PadList;
156 
157  AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
158  AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
159 
160  std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info);
161 
162  inputHandle->Allocate();
163  outputHandle->Allocate();
164 
165  CopyDataToITensorHandle(inputHandle.get(), inputValues.data());
166 
167  workload->PostAllocationConfigure();
168  workload->Execute();
169 
170  CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get());
171 
172  return LayerTestResult<T, 3>(actualOutput,
173  expectedOutputValues,
174  outputHandle->GetShape(),
175  outputTensorInfo.GetShape());
176 }
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 TensorInfos of 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 179 of file PadTestImpl.cpp.

References CopyDataFromITensorHandle(), CopyDataToITensorHandle(), IWorkloadFactory::CreatePad(), ITensorHandleFactory::CreateTensorHandle(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), armnn::IgnoreUnused(), PadDescriptor::m_PadList, and QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters.

185 {
186  IgnoreUnused(memoryManager);
187  const armnn::TensorShape inputShape{ 2, 2, 3, 2 };
188  const armnn::TensorShape outputShape{ 4, 5, 7, 4 };
189 
190  const armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType, qScale, qOffset);
191  const armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType, qScale, qOffset);
192 
193  std::vector<T> inputValues = armnnUtils::QuantizedVector<T>(
194  {
195  // Batch 0, Channel 0, Height (3) x Width (2)
196  0, 1,
197  2, 3,
198  4, 5,
199 
200  // Batch 0, Channel 1, Height (3) x Width (2)
201  6, 7,
202  8, 9,
203  10, 11,
204 
205  // Batch 1, Channel 0, Height (3) x Width (2)
206  12, 13,
207  14, 15,
208  16, 17,
209 
210  // Batch 1, Channel 1, Height (3) x Width (2)
211  18, 19,
212  20, 21,
213  22, 23
214  },
215  qScale, qOffset);
216 
217  std::vector<T> expectedOutputValues = armnnUtils::QuantizedVector<T>(
218  {
219  0, 0, 0, 0,
220  0, 0, 0, 0,
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 
227  0, 0, 0, 0,
228  0, 0, 0, 0,
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 
235  0, 0, 0, 0,
236  0, 0, 0, 0,
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 
243  0, 0, 0, 0,
244  0, 0, 0, 0,
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 
251  0, 0, 0, 0,
252  0, 0, 0, 0,
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 
259  0, 0, 0, 0,
260  0, 0, 0, 0,
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 
267  0, 0, 0, 0,
268  0, 0, 0, 0,
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 
275  0, 0, 0, 0,
276  0, 0, 0, 0,
277  0, 0, 0, 0,
278  0, 0, 1, 0,
279  0, 2, 3, 0,
280  0, 4, 5, 0,
281  0, 0, 0, 0,
282 
283  0, 0, 0, 0,
284  0, 0, 0, 0,
285  0, 0, 0, 0,
286  0, 6, 7, 0,
287  0, 8, 9, 0,
288  0, 10, 11, 0,
289  0, 0, 0, 0,
290 
291  0, 0, 0, 0,
292  0, 0, 0, 0,
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 
299  0, 0, 0, 0,
300  0, 0, 0, 0,
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 
307  0, 0, 0, 0,
308  0, 0, 0, 0,
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 
315  0, 0, 0, 0,
316  0, 0, 0, 0,
317  0, 0, 0, 0,
318  0, 12, 13, 0,
319  0, 14, 15, 0,
320  0, 16, 17, 0,
321  0, 0, 0, 0,
322 
323  0, 0, 0, 0,
324  0, 0, 0, 0,
325  0, 0, 0, 0,
326  0, 18, 19, 0,
327  0, 20, 21, 0,
328  0, 22, 23, 0,
329  0, 0, 0, 0,
330 
331  0, 0, 0, 0,
332  0, 0, 0, 0,
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 
339  0, 0, 0, 0,
340  0, 0, 0, 0,
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 
347  0, 0, 0, 0,
348  0, 0, 0, 0,
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 
355  0, 0, 0, 0,
356  0, 0, 0, 0,
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 
363  0, 0, 0, 0,
364  0, 0, 0, 0,
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 
371  0, 0, 0, 0,
372  0, 0, 0, 0,
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  },
379  qScale, qOffset);
380 
381  std::vector<T> actualOutput(outputTensorInfo.GetNumElements());
382 
383  std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo);
384  std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo);
385 
386  armnn::PadQueueDescriptor descriptor;
387 
388  std::vector<std::pair<unsigned int, unsigned int>> PadList;
389  PadList.push_back(std::pair<unsigned int, unsigned int>(1,1));
390  PadList.push_back(std::pair<unsigned int, unsigned int>(2,1));
391  PadList.push_back(std::pair<unsigned int, unsigned int>(3,1));
392  PadList.push_back(std::pair<unsigned int, unsigned int>(1,1));
393 
394  descriptor.m_Parameters.m_PadList = PadList;
396 
397  AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
398  AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
399 
400  std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info);
401 
402  inputHandle->Allocate();
403  outputHandle->Allocate();
404 
405  CopyDataToITensorHandle(inputHandle.get(), inputValues.data());
406 
407  workload->PostAllocationConfigure();
408  workload->Execute();
409 
410  CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get());
411 
412  return LayerTestResult<T, 4>(actualOutput,
413  expectedOutputValues,
414  outputHandle->GetShape(),
415  outputTensorInfo.GetShape());
416 }
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 TensorInfos of 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 616 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ PadBFloat162dTest()

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

Definition at line 608 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ PadBFloat163dTest()

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

Definition at line 625 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ PadBFloat164dTest()

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

Definition at line 633 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ PadFloat322dCustomPaddingTest()

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

Definition at line 583 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ PadFloat322dTest()

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

Definition at line 575 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ PadFloat323dTest()

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

Definition at line 592 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ PadFloat324dTest()

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

Definition at line 600 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ PadInt82dCustomPaddingTest()

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

Definition at line 650 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ PadInt82dTest()

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

Definition at line 641 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ PadInt83dTest()

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

Definition at line 659 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ PadInt84dTest()

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

Definition at line 667 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ PadInt8AsymmTest()

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

Definition at line 675 of file PadTestImpl.cpp.

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

◆ PadInt8CustomPaddingAsymmTest()

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

Definition at line 684 of file PadTestImpl.cpp.

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

◆ 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 419 of file PadTestImpl.cpp.

References CopyDataFromITensorHandle(), CopyDataToITensorHandle(), IWorkloadFactory::CreatePad(), ITensorHandleFactory::CreateTensorHandle(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), armnn::IgnoreUnused(), PadDescriptor::m_PadList, PadDescriptor::m_PadValue, and QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters.

426 {
427  IgnoreUnused(memoryManager);
428  const armnn::TensorShape inputShape{ 3, 3 };
429  const armnn::TensorShape outputShape{ 7, 7 };
430 
431  const armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType, qScale, qOffset);
432  const armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType, qScale, qOffset);
433 
434  std::vector<T> inputValues =
435  {
436  // Height (3) x Width (3)
437  4, 8, 6,
438  7, 4, 4,
439  3, 2, 4
440  };
441 
442  T p = static_cast<T>(customPaddingValue);
443  std::vector<T> expectedOutputValues =
444  {
445  p, p, p, p, p, p, p,
446  p, p, p, p, p, p, p,
447  p, p, 4, 8, 6, p, p,
448  p, p, 7, 4, 4, p, p,
449  p, p, 3, 2, 4, p, p,
450  p, p, p, p, p, p, p,
451  p, p, p, p, p, p, p
452  };
453 
454  std::vector<T> actualOutput(outputTensorInfo.GetNumElements());
455 
456  std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo);
457  std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo);
458 
459 
460  armnn::PadQueueDescriptor descriptor;
461 
462  std::vector<std::pair<unsigned int, unsigned int>> padList;
463  padList.push_back(std::pair<unsigned int, unsigned int>(2,2));
464  padList.push_back(std::pair<unsigned int, unsigned int>(2,2));
465 
466  descriptor.m_Parameters.m_PadList = padList;
467  descriptor.m_Parameters.m_PadValue = customPaddingValue;
469 
470  AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
471  AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
472 
473  std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info);
474 
475  inputHandle->Allocate();
476  outputHandle->Allocate();
477 
478  CopyDataToITensorHandle(inputHandle.get(), inputValues.data());
479 
480  workload->PostAllocationConfigure();
481  workload->Execute();
482 
483  CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get());
484 
485  return LayerTestResult<T, 2>(actualOutput,
486  expectedOutputValues,
487  outputHandle->GetShape(),
488  outputTensorInfo.GetShape());
489 }
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 TensorInfos of 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 550 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ PadUint82dTest()

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

Definition at line 542 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ PadUint83dTest()

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

Definition at line 559 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ PadUint84dTest()

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

Definition at line 567 of file PadTestImpl.cpp.

Referenced by TEST_SUITE().

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