27 std::size_t OutputDim,
34 const unsigned int *inputShape,
35 const std::vector<float> &inputData,
36 const std::vector<unsigned int> &blockShape,
37 const std::vector<std::pair<unsigned int, unsigned int>> &crops,
38 const unsigned int *outputShape,
39 const std::vector<float> &outputData,
48 inputTensorInfo.SetQuantizationScale(scale);
49 inputTensorInfo.SetQuantizationOffset(offset);
51 outputTensorInfo.SetQuantizationScale(scale);
52 outputTensorInfo.SetQuantizationOffset(offset);
54 auto input = MakeTensor<T, InputDim>(inputTensorInfo, ConvertToDataType<ArmnnType>(inputData, inputTensorInfo));
57 result.outputExpected = MakeTensor<T, OutputDim>(outputTensorInfo,
58 ConvertToDataType<ArmnnType>(outputData, outputTensorInfo));
60 std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.
CreateTensorHandle(inputTensorInfo);
61 std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.
CreateTensorHandle(outputTensorInfo);
68 AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get());
69 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
73 inputHandle->Allocate();
74 outputHandle->Allocate();
78 workload->PostAllocationConfigure();
88 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
94 const unsigned int inputShape[] = {4, 2, 2, 1};
95 const unsigned int outputShape[] = {1, 4, 4, 1};
97 std::vector<float> input({
121 std::vector<float> expectedOutput({
122 1.0f, 2.0f, 3.0f, 4.0f,
123 5.0f, 6.0f, 7.0f, 8.0f,
124 9.0f, 10.0f, 11.0f, 12.0f,
125 13.0f, 14.0f, 15.0f, 16.0f
128 std::vector<unsigned int> blockShape {2, 2};
129 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
131 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
133 crops, outputShape, expectedOutput);
136 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
142 const unsigned int inputShape[] = {4, 1, 1, 1};
143 const unsigned int outputShape[] = {1, 2, 2, 1};
145 std::vector<float> input({
147 1.0f, 2.0f, 3.0f, 4.0f
150 std::vector<float> expectedOutput({1.0f, 2.0f, 3.0f, 4.0f});
152 std::vector<unsigned int> blockShape({2, 2});
153 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
155 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
157 crops, outputShape, expectedOutput);
160 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
166 const unsigned int inputShape[] = {4, 1, 1, 3};
167 const unsigned int outputShape[] = {1, 2, 2, 3};
169 std::vector<float> input({1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f});
171 std::vector<float> expectedOutput({1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f});
173 std::vector<unsigned int> blockShape({2, 2});
174 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
176 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
178 crops, outputShape, expectedOutput);
181 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
187 const unsigned int inputShape[] = {8, 1, 3, 1};
188 const unsigned int outputShape[] = {2, 2, 4, 1};
190 std::vector<float> input({
201 std::vector<float> expectedOutput({
202 1.0f, 2.0f, 3.0f, 4.0f,
203 5.0f, 6.0f, 7.0f, 8.0f,
204 9.0f, 10.0f, 11.0f, 12.0f,
205 13.0f, 14.0f, 15.0f, 16.0f
208 std::vector<unsigned int> blockShape({2, 2});
209 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {2, 0}};
211 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
213 crops, outputShape, expectedOutput);
216 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
222 const unsigned int inputShape[] = {4, 2, 2, 1};
223 const unsigned int outputShape[] = {1, 4, 4, 1};
225 std::vector<float> input({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16});
226 std::vector<float> expectedOutput({1, 5, 2, 6, 9, 13, 10, 14, 3, 7, 4, 8, 11, 15, 12, 16});
228 std::vector<unsigned int> blockShape({2, 2});
229 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
231 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
233 input, blockShape, crops, outputShape, expectedOutput);
236 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
242 const unsigned int inputShape[] = {4, 1, 1, 1};
243 const unsigned int outputShape[] = {1, 2, 2, 1};
245 std::vector<float> input({
250 std::vector<float> expectedOutput({1, 2, 3, 4});
252 std::vector<unsigned int> blockShape({2, 2});
253 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
255 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
257 crops, outputShape, expectedOutput);
260 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
266 const unsigned int inputShape[] = {4, 1, 1, 3};
267 const unsigned int outputShape[] = {1, 2, 2, 3};
269 std::vector<float> input({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
271 std::vector<float> expectedOutput({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
273 std::vector<unsigned int> blockShape({2, 2});
274 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
276 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
278 crops, outputShape, expectedOutput);
281 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
287 const unsigned int inputShape[] = {4, 3, 1, 1};
288 const unsigned int outputShape[] = {1, 3, 2, 2};
290 std::vector<float> input({1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f});
292 std::vector<float> expectedOutput({
306 std::vector<unsigned int> blockShape({2, 2});
307 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
309 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
311 crops, outputShape, expectedOutput);
314 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
320 const unsigned int inputShape[] = {4, 1, 1, 1};
321 const unsigned int outputShape[] = {1, 1, 2, 2};
323 std::vector<float> input({
325 1.0f, 2.0f, 3.0f, 4.0f
328 std::vector<float> expectedOutput({1.0f, 2.0f, 3.0f, 4.0f});
330 std::vector<unsigned int> blockShape({2, 2});
331 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
333 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
335 crops, outputShape, expectedOutput);
338 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
344 const unsigned int inputShape[] = {4, 3, 1, 1};
345 const unsigned int outputShape[] = {1, 3, 2, 2};
347 std::vector<float> input({1.0f, 3.0f, 5.0f, 7.0f, 9.0f, 11.0f, 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f});
349 std::vector<float> expectedOutput({
363 std::vector<unsigned int> blockShape({2, 2});
364 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
366 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
368 crops, outputShape, expectedOutput);
371 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
377 const unsigned int inputShape[] = {4, 3, 1, 1};
378 const unsigned int outputShape[] = {1, 3, 2, 2};
380 std::vector<float> input({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
382 std::vector<float> expectedOutput({
396 std::vector<unsigned int> blockShape({2, 2});
397 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
399 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
401 crops, outputShape, expectedOutput);
404 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
410 const unsigned int inputShape[] = {4, 1, 1, 1};
411 const unsigned int outputShape[] = {1, 1, 2, 2};
413 std::vector<float> input({
418 std::vector<float> expectedOutput({1, 2, 3, 4});
420 std::vector<unsigned int> blockShape({2, 2});
421 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
423 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
425 crops, outputShape, expectedOutput);
428 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
434 const unsigned int inputShape[] = {4, 3, 1, 1};
435 const unsigned int outputShape[] = {1, 3, 2, 2};
437 std::vector<float> input({1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10, 12});
439 std::vector<float> expectedOutput({
453 std::vector<unsigned int> blockShape({2, 2});
454 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
456 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
458 crops, outputShape, expectedOutput);
461 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
467 const unsigned int inputShape[] = {8, 1, 1, 3};
468 const unsigned int outputShape[] = {2, 1, 2, 4};
470 std::vector<float> input({
477 std::vector<float> expectedOutput({
484 std::vector<unsigned int> blockShape({2, 2});
485 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {2, 0}};
487 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
489 crops, outputShape, expectedOutput);
virtual std::unique_ptr< IWorkload > CreateBatchToSpaceNd(const BatchToSpaceNdQueueDescriptor &descriptor, const WorkloadInfo &Info) const
LayerTestResult< T, 4 > BatchToSpaceNdNhwcTest2(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< T, 4 > BatchToSpaceNdNchwTest3(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< T, 4 > BatchToSpaceNdNchwTest2(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< T, 4 > BatchToSpaceNdNhwcTest1(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< T, 4 > BatchToSpaceNdNhwcTest5(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
typename ResolveTypeImpl< DT >::Type ResolveType
LayerTestResult< T, 4 > BatchToSpaceNdNhwcTest6(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
void IgnoreUnused(Ts &&...)
LayerDescriptor m_Parameters
LayerTestResult< T, 4 > BatchToSpaceNdNhwcTest7(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< T, 4 > BatchToSpaceNdNchwTest7(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
std::vector< unsigned int > m_BlockShape
Block shape values.
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
LayerTestResult< T, 4 > BatchToSpaceNdNchwTest1(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
void CopyDataFromITensorHandle(void *memory, const armnn::ITensorHandle *tensorHandle)
std::vector< std::pair< unsigned int, unsigned int > > m_Crops
The values to crop from the input dimension.
Contains information about inputs and outputs to a layer.
LayerTestResult< T, 4 > BatchToSpaceNdNhwcTest3(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< T, 4 > BatchToSpaceNdNchwTest6(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< T, 4 > BatchToSpaceNdNchwTest4(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
virtual std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const =0
LayerTestResult< T, 4 > BatchToSpaceNdNhwcTest4(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
void CopyDataToITensorHandle(armnn::ITensorHandle *tensorHandle, const void *memory)
LayerTestResult< T, 4 > BatchToSpaceNdNchwTest5(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)