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 std::vector<T> input = ConvertToDataType<ArmnnType>(inputData, inputTensorInfo);
56 std::vector<T> actualOutput(outputTensorInfo.GetNumElements());
57 std::vector<T> expectedOutput = ConvertToDataType<ArmnnType>(outputData, outputTensorInfo);
59 std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.
CreateTensorHandle(inputTensorInfo);
60 std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.
CreateTensorHandle(outputTensorInfo);
67 AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get());
68 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
72 inputHandle->Allocate();
73 outputHandle->Allocate();
77 workload->PostAllocationConfigure();
84 outputHandle->GetShape(),
85 outputTensorInfo.GetShape());
90 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
96 const unsigned int inputShape[] = {4, 2, 2, 1};
97 const unsigned int outputShape[] = {1, 4, 4, 1};
99 std::vector<float> input({
123 std::vector<float> expectedOutput({
124 1.0f, 2.0f, 3.0f, 4.0f,
125 5.0f, 6.0f, 7.0f, 8.0f,
126 9.0f, 10.0f, 11.0f, 12.0f,
127 13.0f, 14.0f, 15.0f, 16.0f
130 std::vector<unsigned int> blockShape {2, 2};
131 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
133 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
135 crops, outputShape, expectedOutput);
138 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
144 const unsigned int inputShape[] = {4, 1, 1, 1};
145 const unsigned int outputShape[] = {1, 2, 2, 1};
147 std::vector<float> input({
149 1.0f, 2.0f, 3.0f, 4.0f
152 std::vector<float> expectedOutput({1.0f, 2.0f, 3.0f, 4.0f});
154 std::vector<unsigned int> blockShape({2, 2});
155 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
157 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
159 crops, outputShape, expectedOutput);
162 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
168 const unsigned int inputShape[] = {4, 1, 1, 3};
169 const unsigned int outputShape[] = {1, 2, 2, 3};
171 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});
173 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});
175 std::vector<unsigned int> blockShape({2, 2});
176 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
178 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
180 crops, outputShape, expectedOutput);
183 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
189 const unsigned int inputShape[] = {8, 1, 3, 1};
190 const unsigned int outputShape[] = {2, 2, 4, 1};
192 std::vector<float> input({
203 std::vector<float> expectedOutput({
204 1.0f, 2.0f, 3.0f, 4.0f,
205 5.0f, 6.0f, 7.0f, 8.0f,
206 9.0f, 10.0f, 11.0f, 12.0f,
207 13.0f, 14.0f, 15.0f, 16.0f
210 std::vector<unsigned int> blockShape({2, 2});
211 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {2, 0}};
213 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
215 crops, outputShape, expectedOutput);
218 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
224 const unsigned int inputShape[] = {4, 2, 2, 1};
225 const unsigned int outputShape[] = {1, 4, 4, 1};
227 std::vector<float> input({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16});
228 std::vector<float> expectedOutput({1, 5, 2, 6, 9, 13, 10, 14, 3, 7, 4, 8, 11, 15, 12, 16});
230 std::vector<unsigned int> blockShape({2, 2});
231 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
233 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
235 input, blockShape, crops, outputShape, expectedOutput);
238 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
244 const unsigned int inputShape[] = {4, 1, 1, 1};
245 const unsigned int outputShape[] = {1, 2, 2, 1};
247 std::vector<float> input({
252 std::vector<float> expectedOutput({1, 2, 3, 4});
254 std::vector<unsigned int> blockShape({2, 2});
255 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
257 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
259 crops, outputShape, expectedOutput);
262 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
268 const unsigned int inputShape[] = {4, 1, 1, 3};
269 const unsigned int outputShape[] = {1, 2, 2, 3};
271 std::vector<float> input({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
273 std::vector<float> expectedOutput({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
275 std::vector<unsigned int> blockShape({2, 2});
276 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
278 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
280 crops, outputShape, expectedOutput);
283 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
289 const unsigned int inputShape[] = {4, 3, 1, 1};
290 const unsigned int outputShape[] = {1, 3, 2, 2};
292 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});
294 std::vector<float> expectedOutput({
308 std::vector<unsigned int> blockShape({2, 2});
309 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
311 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
313 crops, outputShape, expectedOutput);
316 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
322 const unsigned int inputShape[] = {4, 1, 1, 1};
323 const unsigned int outputShape[] = {1, 1, 2, 2};
325 std::vector<float> input({
327 1.0f, 2.0f, 3.0f, 4.0f
330 std::vector<float> expectedOutput({1.0f, 2.0f, 3.0f, 4.0f});
332 std::vector<unsigned int> blockShape({2, 2});
333 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
335 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
337 crops, outputShape, expectedOutput);
340 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
346 const unsigned int inputShape[] = {4, 3, 1, 1};
347 const unsigned int outputShape[] = {1, 3, 2, 2};
349 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});
351 std::vector<float> expectedOutput({
365 std::vector<unsigned int> blockShape({2, 2});
366 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
368 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
370 crops, outputShape, expectedOutput);
373 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
379 const unsigned int inputShape[] = {4, 3, 1, 1};
380 const unsigned int outputShape[] = {1, 3, 2, 2};
382 std::vector<float> input({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
384 std::vector<float> expectedOutput({
398 std::vector<unsigned int> blockShape({2, 2});
399 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
401 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
403 crops, outputShape, expectedOutput);
406 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
412 const unsigned int inputShape[] = {4, 1, 1, 1};
413 const unsigned int outputShape[] = {1, 1, 2, 2};
415 std::vector<float> input({
420 std::vector<float> expectedOutput({1, 2, 3, 4});
422 std::vector<unsigned int> blockShape({2, 2});
423 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
425 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
427 crops, outputShape, expectedOutput);
430 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
436 const unsigned int inputShape[] = {4, 3, 1, 1};
437 const unsigned int outputShape[] = {1, 3, 2, 2};
439 std::vector<float> input({1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10, 12});
441 std::vector<float> expectedOutput({
455 std::vector<unsigned int> blockShape({2, 2});
456 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
458 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
460 crops, outputShape, expectedOutput);
463 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
469 const unsigned int inputShape[] = {8, 1, 1, 3};
470 const unsigned int outputShape[] = {2, 1, 2, 4};
472 std::vector<float> input({
479 std::vector<float> expectedOutput({
486 std::vector<unsigned int> blockShape({2, 2});
487 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {2, 0}};
489 return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, tensorHandleFactory,
491 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 TensorInfos of 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)