aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancis Murtagh <francis.murtagh@arm.com>2019-06-24 14:24:36 +0100
committerMatthew Bentham <matthew.bentham@arm.com>2019-06-25 08:48:10 +0000
commit57f13d5905a1fbdc89b53d68b2bdc6b753b9e8d5 (patch)
treea982eecfcb9cde7c8326034f7af4a333a2ab66b8
parent34757810f8b734f5f59485a542b56934ad4cc5f0 (diff)
downloadarmnn-57f13d5905a1fbdc89b53d68b2bdc6b753b9e8d5.tar.gz
IVGCVSW-3334 Refactor BatchToSpace tests to be generic
* Generify and reformat test BatchToSpace tests * Add missing RefCreateWorkload test Change-Id: I08af018c07ee41df5b9d1e578d99bc03f38090ac Signed-off-by: Francis Murtagh <francis.murtagh@arm.com>
-rw-r--r--src/armnn/test/CreateWorkload.hpp29
-rw-r--r--src/backends/backendsCommon/test/LayerTests.cpp432
-rw-r--r--src/backends/backendsCommon/test/LayerTests.hpp475
-rw-r--r--src/backends/cl/test/ClLayerTests.cpp24
-rw-r--r--src/backends/reference/test/RefCreateWorkloadTests.cpp23
-rw-r--r--src/backends/reference/test/RefLayerTests.cpp52
6 files changed, 559 insertions, 476 deletions
diff --git a/src/armnn/test/CreateWorkload.hpp b/src/armnn/test/CreateWorkload.hpp
index 47af4a89b5..00257ea090 100644
--- a/src/armnn/test/CreateWorkload.hpp
+++ b/src/armnn/test/CreateWorkload.hpp
@@ -914,6 +914,35 @@ std::unique_ptr<RsqrtWorkload> CreateRsqrtWorkloadTest(armnn::IWorkloadFactory&
return workload;
}
+template <typename BatchToSpaceNdWorkload, armnn::DataType DataType>
+std::unique_ptr<BatchToSpaceNdWorkload> CreateBatchToSpaceNdWorkloadTest(armnn::IWorkloadFactory& factory,
+ armnn::Graph& graph)
+{
+ BatchToSpaceNdDescriptor desc;
+ Layer* const layer = graph.AddLayer<BatchToSpaceNdLayer>(desc, "batchToSpace");
+
+ // Creates extra layers.
+ Layer* const input = graph.AddLayer<InputLayer>(0, "input");
+ Layer* const output = graph.AddLayer<OutputLayer>(0, "output");
+
+ // Connects up.
+ armnn::TensorInfo tensorInfo({1, 1}, DataType);
+
+ Connect(input, layer, tensorInfo);
+ Connect(layer, output, tensorInfo);
+
+ CreateTensorHandles(graph, factory);
+
+ // Makes the workload and checks it.
+ auto workload = MakeAndCheckWorkload<BatchToSpaceNdWorkload>(*layer, graph, factory);
+
+ BatchToSpaceNdQueueDescriptor queueDescriptor = workload->GetData();
+ BOOST_TEST(queueDescriptor.m_Inputs.size() == 1);
+ BOOST_TEST(queueDescriptor.m_Outputs.size() == 1);
+
+ return workload;
+}
+
template <typename L2NormalizationWorkload, armnn::DataType DataType>
std::unique_ptr<L2NormalizationWorkload> CreateL2NormalizationWorkloadTest(armnn::IWorkloadFactory& factory,
armnn::Graph& graph, DataLayout dataLayout = DataLayout::NCHW)
diff --git a/src/backends/backendsCommon/test/LayerTests.cpp b/src/backends/backendsCommon/test/LayerTests.cpp
index c9a5731190..64b9676a4b 100644
--- a/src/backends/backendsCommon/test/LayerTests.cpp
+++ b/src/backends/backendsCommon/test/LayerTests.cpp
@@ -9290,440 +9290,8 @@ LayerTestResult<float, 4> SpaceToDepthNCHWFloat32Test(
namespace {
-template<typename T, std::size_t InputDim, std::size_t OutputDim>
-LayerTestResult<T, OutputDim> BatchToSpaceNdHelper(
- armnn::IWorkloadFactory &workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
- const armnn::DataLayout& dataLayout,
- const unsigned int *inputShape,
- const std::vector<T> &inputData,
- const std::vector<unsigned int> &blockShape,
- const std::vector<std::pair<unsigned int, unsigned int>> &crops,
- const unsigned int *outputShape,
- const std::vector<T> &outputData,
- float scale = 1.0f,
- int32_t offset = 0)
-{
- auto dataType = (std::is_same<T, uint8_t>::value ? armnn::DataType::QuantisedAsymm8 : armnn::DataType::Float32);
-
- armnn::TensorInfo inputTensorInfo(InputDim, inputShape, dataType);
- armnn::TensorInfo outputTensorInfo(OutputDim, outputShape, dataType);
-
- inputTensorInfo.SetQuantizationScale(scale);
- inputTensorInfo.SetQuantizationOffset(offset);
-
- outputTensorInfo.SetQuantizationScale(scale);
- outputTensorInfo.SetQuantizationOffset(offset);
-
- auto input = MakeTensor<T, InputDim>(inputTensorInfo, inputData);
-
- LayerTestResult<T, OutputDim> result(outputTensorInfo);
- result.outputExpected = MakeTensor<T, OutputDim>(outputTensorInfo, outputData);
-
- std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
- std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
-
- armnn::BatchToSpaceNdQueueDescriptor data;
- data.m_Parameters.m_DataLayout = dataLayout;
- data.m_Parameters.m_BlockShape = blockShape;
- data.m_Parameters.m_Crops = crops;
- armnn::WorkloadInfo info;
- AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get());
- AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
-
- std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateBatchToSpaceNd(data, info);
-
- inputHandle->Allocate();
- outputHandle->Allocate();
-
- CopyDataToITensorHandle(inputHandle.get(), input.origin());
-
- workload->PostAllocationConfigure();
- workload->Execute();
-
- CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
-
- return result;
-}
-
} // anonymous namespace
-LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test1(
- armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
-{
- const unsigned int inputShape[] = {4, 2, 2, 1};
- const unsigned int outputShape[] = {1, 4, 4, 1};
-
- std::vector<float> input({
- // Batch 0, Height 0, Width (2) x Channel (1)
- 1.0f, 3.0f,
- // Batch 0, Height 1, Width (2) x Channel (1)
- 9.0f, 11.0f,
-
-
- // Batch 1, Height 0, Width (2) x Channel (1)
- 2.0f, 4.0f,
- // Batch 1, Height 1, Width (2) x Channel (1)
- 10.0f, 12.0f,
-
-
- // Batch 2, Height 0, Width (2) x Channel (1)
- 5.0f, 7.0f,
- // Batch 2, Height 1, Width (2) x Channel (1)
- 13.0f, 15.0f,
-
- // Batch 3, Height 0, Width (2) x Channel (3)
- 6.0f, 8.0f,
- // Batch 3, Height 1, Width (2) x Channel (1)
- 14.0f, 16.0f
- });
-
- 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,
- 13.0f, 14.0f, 15.0f, 16.0f
- });
-
- std::vector<unsigned int> blockShape {2, 2};
- std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
-
- return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager,
- armnn::DataLayout::NHWC, inputShape, input, blockShape,
- crops, outputShape, expectedOutput);
-}
-
-LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test2(
- armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
-{
- const unsigned int inputShape[] = {4, 1, 1, 1};
- const unsigned int outputShape[] = {1, 2, 2, 1};
-
- std::vector<float> input({
- // Batch 0, Height 0, Width (2) x Channel (1)
- 1.0f, 2.0f, 3.0f, 4.0f
- });
-
- std::vector<float> expectedOutput({1.0f, 2.0f, 3.0f, 4.0f});
-
- std::vector<unsigned int> blockShape({2, 2});
- std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
-
- return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager,
- armnn::DataLayout::NHWC, inputShape, input, blockShape,
- crops, outputShape, expectedOutput);
-}
-
-LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test3(
- armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
-{
- const unsigned int inputShape[] = {4, 1, 1, 3};
- const unsigned int outputShape[] = {1, 2, 2, 3};
-
- 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});
-
- 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});
-
- std::vector<unsigned int> blockShape({2, 2});
- std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
-
- return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager,
- armnn::DataLayout::NHWC, inputShape, input, blockShape,
- crops, outputShape, expectedOutput);
-}
-
-LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test4(
- armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
-{
- const unsigned int inputShape[] = {8, 1, 3, 1};
- const unsigned int outputShape[] = {2, 2, 4, 1};
-
- std::vector<float> input({
- 0.0f, 1.0f, 3.0f,
- 0.0f, 9.0f, 11.0f,
- 0.0f, 2.0f, 4.0f,
- 0.0f, 10.0f, 12.0f,
- 0.0f, 5.0f, 7.0f,
- 0.0f, 13.0f, 15.0f,
- 0.0f, 6.0f, 8.0f,
- 0.0f, 14.0f, 16.0f
- });
-
- 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,
- 13.0f, 14.0f, 15.0f, 16.0f
- });
-
- std::vector<unsigned int> blockShape({2, 2});
- std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {2, 0}};
-
- return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager,
- armnn::DataLayout::NHWC, inputShape, input, blockShape,
- crops, outputShape, expectedOutput);
-}
-
-LayerTestResult<float, 4> BatchToSpaceNdNchwFloat32Test1(
- armnn::IWorkloadFactory &workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
-{
- const unsigned int inputShape[] = {4, 3, 1, 1};
- const unsigned int outputShape[] = {1, 3, 2, 2};
-
- 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});
-
- std::vector<float> expectedOutput({
- // Batch 0, Channel 0, Height (2) x Width (2)
- 1.0f, 4.0f,
- 7.0f, 10.0f,
-
- // Batch 0, Channel 1, Height (2) x Width (2)
- 2.0f, 5.0f,
- 8.0f, 11.0f,
-
- // Batch 0, Channel 2, Height (2) x Width (2)
- 3.0f, 6.0f,
- 9.0f, 12.0f,
- });
-
- std::vector<unsigned int> blockShape({2, 2});
- std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
-
- return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager,
- armnn::DataLayout::NCHW, inputShape, input, blockShape,
- crops, outputShape, expectedOutput);
-}
-
-LayerTestResult<float, 4> BatchToSpaceNdNchwFloat32Test2(
- armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
-{
- const unsigned int inputShape[] = {4, 1, 1, 1};
- const unsigned int outputShape[] = {1, 1, 2, 2};
-
- std::vector<float> input({
- // Batch 0, Height 0, Width (2) x Channel (1)
- 1.0f, 2.0f, 3.0f, 4.0f
- });
-
- std::vector<float> expectedOutput({1.0f, 2.0f, 3.0f, 4.0f});
-
- std::vector<unsigned int> blockShape({2, 2});
- std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
-
- return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager,
- armnn::DataLayout::NCHW, inputShape, input, blockShape,
- crops, outputShape, expectedOutput);
-}
-
-LayerTestResult<float, 4> BatchToSpaceNdNchwFloat32Test3(
- armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
-{
- const unsigned int inputShape[] = {4, 3, 1, 1};
- const unsigned int outputShape[] = {1, 3, 2, 2};
-
- 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});
-
- std::vector<float> expectedOutput({
- // Batch 0, Channel 0, Height (2) x Width (2)
- 1.0f, 7.0f,
- 2.0f, 8.0f,
-
- // Batch 0, Channel 1, Height (2) x Width (2)
- 3.0f, 9.0f,
- 4.0f, 10.0f,
-
- // Batch 0, Channel 2, Height (2) x Width (2)
- 5.0f, 11.0f,
- 6.0f, 12.0f,
- });
-
- std::vector<unsigned int> blockShape({2, 2});
- std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
-
- return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager,
- armnn::DataLayout::NCHW, inputShape, input, blockShape,
- crops, outputShape, expectedOutput);
-}
-
-LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcUintTest1(
- armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
-{
- const unsigned int inputShape[] = {4, 2, 2, 1};
- const unsigned int outputShape[] = {1, 4, 4, 1};
-
- std::vector<uint8_t> input({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16});
- std::vector<uint8_t> expectedOutput({1, 5, 2, 6, 9, 13, 10, 14, 3, 7, 4, 8, 11, 15, 12, 16});
-
- std::vector<unsigned int> blockShape({2, 2});
- std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
-
- return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager, armnn::DataLayout::NHWC, inputShape,
- input, blockShape, crops, outputShape, expectedOutput);
-}
-
-LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcUintTest2(
- armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
-{
- const unsigned int inputShape[] = {4, 1, 1, 1};
- const unsigned int outputShape[] = {1, 2, 2, 1};
-
- std::vector<uint8_t> input({
- // Batch 0, Height 0, Width (2) x Channel (1)
- 1, 2, 3, 4
- });
-
- std::vector<uint8_t> expectedOutput({1, 2, 3, 4});
-
- std::vector<unsigned int> blockShape({2, 2});
- std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
-
- return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager,
- armnn::DataLayout::NHWC, inputShape, input, blockShape,
- crops, outputShape, expectedOutput);
-}
-
-LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcUintTest3(
- armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
-{
- const unsigned int inputShape[] = {4, 1, 1, 3};
- const unsigned int outputShape[] = {1, 2, 2, 3};
-
- std::vector<uint8_t> input({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
-
- std::vector<uint8_t> expectedOutput({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
-
- std::vector<unsigned int> blockShape({2, 2});
- std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
-
- return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager,
- armnn::DataLayout::NHWC, inputShape, input, blockShape,
- crops, outputShape, expectedOutput);
-}
-
-
-LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest1(
- armnn::IWorkloadFactory &workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
-{
- const unsigned int inputShape[] = {4, 3, 1, 1};
- const unsigned int outputShape[] = {1, 3, 2, 2};
-
- std::vector<uint8_t> input({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
-
- std::vector<uint8_t> expectedOutput({
- // Batch 0, Channel 0, Height (2) x Width (2)
- 1, 4,
- 7, 10,
-
- // Batch 0, Channel 1, Height (2) x Width (2)
- 2, 5,
- 8, 11,
-
- // Batch 0, Channel 2, Height (2) x Width (2)
- 3, 6,
- 9, 12,
- });
-
- std::vector<unsigned int> blockShape({2, 2});
- std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
-
- return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager,
- armnn::DataLayout::NCHW, inputShape, input, blockShape,
- crops, outputShape, expectedOutput);
-}
-
-LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest2(
- armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
-{
- const unsigned int inputShape[] = {4, 1, 1, 1};
- const unsigned int outputShape[] = {1, 1, 2, 2};
-
- std::vector<uint8_t> input({
- // Batch 0, Height 0, Width (2) x Channel (1)
- 1, 2, 3, 4
- });
-
- std::vector<uint8_t> expectedOutput({1, 2, 3, 4});
-
- std::vector<unsigned int> blockShape({2, 2});
- std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
-
- return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager,
- armnn::DataLayout::NCHW, inputShape, input, blockShape,
- crops, outputShape, expectedOutput);
-}
-
-LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest3(
- armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
-{
- const unsigned int inputShape[] = {4, 3, 1, 1};
- const unsigned int outputShape[] = {1, 3, 2, 2};
-
- std::vector<uint8_t> input({1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10, 12});
-
- std::vector<uint8_t> expectedOutput({
- // Batch 0, Channel 0, Height (2) x Width (2)
- 1, 7,
- 2, 8,
-
- // Batch 0, Channel 1, Height (2) x Width (2)
- 3, 9,
- 4, 10,
-
- // Batch 0, Channel 2, Height (2) x Width (2)
- 5, 11,
- 6, 12,
- });
-
- std::vector<unsigned int> blockShape({2, 2});
- std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
-
- return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager,
- armnn::DataLayout::NCHW, inputShape, input, blockShape,
- crops, outputShape, expectedOutput);
-}
-
-LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest4(
- armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
-{
- const unsigned int inputShape[] = {8, 1, 1, 3};
- const unsigned int outputShape[] = {2, 1, 2, 4};
-
- std::vector<uint8_t> input({
- 0, 1, 3, 0, 9, 11,
- 0, 2, 4, 0, 10, 12,
- 0, 5, 7, 0, 13, 15,
- 0, 6, 8, 0, 14, 16
- });
-
- std::vector<uint8_t> expectedOutput({
- 1, 2, 3, 4,
- 5, 6, 7, 8,
- 9, 10, 11, 12,
- 13, 14, 15, 16
- });
-
- std::vector<unsigned int> blockShape({2, 2});
- std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {2, 0}};
-
- return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager,
- armnn::DataLayout::NCHW, inputShape, input, blockShape,
- crops, outputShape, expectedOutput);
-}
-
LayerTestResult<float, 4> StridedSlice4DFloat32Test(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
diff --git a/src/backends/backendsCommon/test/LayerTests.hpp b/src/backends/backendsCommon/test/LayerTests.hpp
index be16819990..77adca1ac7 100644
--- a/src/backends/backendsCommon/test/LayerTests.hpp
+++ b/src/backends/backendsCommon/test/LayerTests.hpp
@@ -1653,59 +1653,59 @@ LayerTestResult<int16_t, 4> SpaceToBatchNdPaddingNHWCUint16Test(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
-LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test1(
+LayerTestResult<float, 4> BatchToSpaceNdNhwcTest1(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
-LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test2(
+LayerTestResult<float, 4> BatchToSpaceNdNhwcTest2(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
-LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test3(
+LayerTestResult<float, 4> BatchToSpaceNdNhwcTest3(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
-LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test4(
+LayerTestResult<float, 4> BatchToSpaceNdNhwcTest4(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
-LayerTestResult<float, 4> BatchToSpaceNdNchwFloat32Test1(
+LayerTestResult<float, 4> BatchToSpaceNdNchwTest1(
armnn::IWorkloadFactory &workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
-LayerTestResult<float, 4> BatchToSpaceNdNchwFloat32Test2(
+LayerTestResult<float, 4> BatchToSpaceNdNchwTest2(
armnn::IWorkloadFactory &workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
-LayerTestResult<float, 4> BatchToSpaceNdNchwFloat32Test3(
+LayerTestResult<float, 4> BatchToSpaceNdNchwTest3(
armnn::IWorkloadFactory &workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
-LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcUintTest1(
+LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcTest5(
armnn::IWorkloadFactory &workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
-LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcUintTest2(
+LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcTest6(
armnn::IWorkloadFactory &workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
-LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcUintTest3(
+LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcTest7(
armnn::IWorkloadFactory &workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
-LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest1(
+LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwTest4(
armnn::IWorkloadFactory &workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
-LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest2(
+LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwTest5(
armnn::IWorkloadFactory &workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
-LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest3(
+LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwTest6(
armnn::IWorkloadFactory &workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
-LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest4(
+LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwTest7(
armnn::IWorkloadFactory &workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
@@ -3287,6 +3287,453 @@ LayerTestResult<T, 4> PreluTest(
return result;
}
+template<armnn::DataType ArmnnType,
+ std::size_t InputDim,
+ std::size_t OutputDim,
+ typename T = armnn::ResolveType<ArmnnType>>
+LayerTestResult<T, OutputDim> BatchToSpaceNdHelper(
+ armnn::IWorkloadFactory &workloadFactory,
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ const armnn::DataLayout& dataLayout,
+ const unsigned int *inputShape,
+ const std::vector<float> &inputData,
+ const std::vector<unsigned int> &blockShape,
+ const std::vector<std::pair<unsigned int, unsigned int>> &crops,
+ const unsigned int *outputShape,
+ const std::vector<float> &outputData,
+ float scale = 1.0f,
+ int32_t offset = 0)
+{
+ armnn::TensorInfo inputTensorInfo(InputDim, inputShape, ArmnnType);
+ armnn::TensorInfo outputTensorInfo(OutputDim, outputShape, ArmnnType);
+
+ inputTensorInfo.SetQuantizationScale(scale);
+ inputTensorInfo.SetQuantizationOffset(offset);
+
+ outputTensorInfo.SetQuantizationScale(scale);
+ outputTensorInfo.SetQuantizationOffset(offset);
+;
+ auto input = MakeTensor<T, InputDim>(inputTensorInfo, ConvertToDataType<ArmnnType>(inputData, inputTensorInfo));
+
+ LayerTestResult<T, OutputDim> result(outputTensorInfo);
+ result.outputExpected = MakeTensor<T, OutputDim>(outputTensorInfo,
+ ConvertToDataType<ArmnnType>(outputData, outputTensorInfo));
+
+ std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
+ std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
+
+ armnn::BatchToSpaceNdQueueDescriptor data;
+ data.m_Parameters.m_DataLayout = dataLayout;
+ data.m_Parameters.m_BlockShape = blockShape;
+ data.m_Parameters.m_Crops = crops;
+ armnn::WorkloadInfo info;
+ AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get());
+ AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
+
+ std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateBatchToSpaceNd(data, info);
+
+ inputHandle->Allocate();
+ outputHandle->Allocate();
+
+ CopyDataToITensorHandle(inputHandle.get(), input.origin());
+
+ workload->PostAllocationConfigure();
+ workload->Execute();
+
+ CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
+
+ return result;
+}
+
+template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
+LayerTestResult<T, 4> BatchToSpaceNdNhwcTest1(
+ armnn::IWorkloadFactory& workloadFactory,
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+{
+ const unsigned int inputShape[] = {4, 2, 2, 1};
+ const unsigned int outputShape[] = {1, 4, 4, 1};
+
+ std::vector<float> input({
+ // Batch 0, Height 0, Width (2) x Channel (1)
+ 1.0f, 3.0f,
+ // Batch 0, Height 1, Width (2) x Channel (1)
+ 9.0f, 11.0f,
+
+
+ // Batch 1, Height 0, Width (2) x Channel (1)
+ 2.0f, 4.0f,
+ // Batch 1, Height 1, Width (2) x Channel (1)
+ 10.0f, 12.0f,
+
+
+ // Batch 2, Height 0, Width (2) x Channel (1)
+ 5.0f, 7.0f,
+ // Batch 2, Height 1, Width (2) x Channel (1)
+ 13.0f, 15.0f,
+
+ // Batch 3, Height 0, Width (2) x Channel (3)
+ 6.0f, 8.0f,
+ // Batch 3, Height 1, Width (2) x Channel (1)
+ 14.0f, 16.0f
+ });
+
+ 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,
+ 13.0f, 14.0f, 15.0f, 16.0f
+ });
+
+ std::vector<unsigned int> blockShape {2, 2};
+ std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
+
+ return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager,
+ armnn::DataLayout::NHWC, inputShape, input, blockShape,
+ crops, outputShape, expectedOutput);
+}
+
+template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
+LayerTestResult<T, 4> BatchToSpaceNdNhwcTest2(
+ armnn::IWorkloadFactory& workloadFactory,
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+{
+ const unsigned int inputShape[] = {4, 1, 1, 1};
+ const unsigned int outputShape[] = {1, 2, 2, 1};
+
+ std::vector<float> input({
+ // Batch 0, Height 0, Width (2) x Channel (1)
+ 1.0f, 2.0f, 3.0f, 4.0f
+ });
+
+ std::vector<float> expectedOutput({1.0f, 2.0f, 3.0f, 4.0f});
+
+ std::vector<unsigned int> blockShape({2, 2});
+ std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
+
+ return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager,
+ armnn::DataLayout::NHWC, inputShape, input, blockShape,
+ crops, outputShape, expectedOutput);
+}
+
+template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
+LayerTestResult<T, 4> BatchToSpaceNdNhwcTest3(
+ armnn::IWorkloadFactory& workloadFactory,
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+{
+ const unsigned int inputShape[] = {4, 1, 1, 3};
+ const unsigned int outputShape[] = {1, 2, 2, 3};
+
+ 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});
+
+ 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});
+
+ std::vector<unsigned int> blockShape({2, 2});
+ std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
+
+ return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager,
+ armnn::DataLayout::NHWC, inputShape, input, blockShape,
+ crops, outputShape, expectedOutput);
+}
+
+template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
+LayerTestResult<T, 4> BatchToSpaceNdNhwcTest4(
+ armnn::IWorkloadFactory& workloadFactory,
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+{
+ const unsigned int inputShape[] = {8, 1, 3, 1};
+ const unsigned int outputShape[] = {2, 2, 4, 1};
+
+ std::vector<float> input({
+ 0.0f, 1.0f, 3.0f,
+ 0.0f, 9.0f, 11.0f,
+ 0.0f, 2.0f, 4.0f,
+ 0.0f, 10.0f, 12.0f,
+ 0.0f, 5.0f, 7.0f,
+ 0.0f, 13.0f, 15.0f,
+ 0.0f, 6.0f, 8.0f,
+ 0.0f, 14.0f, 16.0f
+ });
+
+ 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,
+ 13.0f, 14.0f, 15.0f, 16.0f
+ });
+
+ std::vector<unsigned int> blockShape({2, 2});
+ std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {2, 0}};
+
+ return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager,
+ armnn::DataLayout::NHWC, inputShape, input, blockShape,
+ crops, outputShape, expectedOutput);
+}
+
+template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
+LayerTestResult<T, 4> BatchToSpaceNdNhwcTest5(
+ armnn::IWorkloadFactory& workloadFactory,
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+{
+ const unsigned int inputShape[] = {4, 2, 2, 1};
+ const unsigned int outputShape[] = {1, 4, 4, 1};
+
+ std::vector<float> input({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16});
+ std::vector<float> expectedOutput({1, 5, 2, 6, 9, 13, 10, 14, 3, 7, 4, 8, 11, 15, 12, 16});
+
+ std::vector<unsigned int> blockShape({2, 2});
+ std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
+
+ return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager, armnn::DataLayout::NHWC, inputShape,
+ input, blockShape, crops, outputShape, expectedOutput);
+}
+
+template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
+LayerTestResult<T, 4> BatchToSpaceNdNhwcTest6(
+ armnn::IWorkloadFactory& workloadFactory,
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+{
+ const unsigned int inputShape[] = {4, 1, 1, 1};
+ const unsigned int outputShape[] = {1, 2, 2, 1};
+
+ std::vector<float> input({
+ // Batch 0, Height 0, Width (2) x Channel (1)
+ 1, 2, 3, 4
+ });
+
+ std::vector<float> expectedOutput({1, 2, 3, 4});
+
+ std::vector<unsigned int> blockShape({2, 2});
+ std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
+
+ return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager,
+ armnn::DataLayout::NHWC, inputShape, input, blockShape,
+ crops, outputShape, expectedOutput);
+}
+
+template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
+LayerTestResult<T, 4> BatchToSpaceNdNhwcTest7(
+ armnn::IWorkloadFactory& workloadFactory,
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+{
+ const unsigned int inputShape[] = {4, 1, 1, 3};
+ const unsigned int outputShape[] = {1, 2, 2, 3};
+
+ std::vector<float> input({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
+
+ std::vector<float> expectedOutput({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
+
+ std::vector<unsigned int> blockShape({2, 2});
+ std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
+
+ return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager,
+ armnn::DataLayout::NHWC, inputShape, input, blockShape,
+ crops, outputShape, expectedOutput);
+}
+
+template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
+LayerTestResult<T, 4> BatchToSpaceNdNchwTest1(
+ armnn::IWorkloadFactory &workloadFactory,
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+{
+ const unsigned int inputShape[] = {4, 3, 1, 1};
+ const unsigned int outputShape[] = {1, 3, 2, 2};
+
+ 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});
+
+ std::vector<float> expectedOutput({
+ // Batch 0, Channel 0, Height (2) x Width (2)
+ 1.0f, 4.0f,
+ 7.0f, 10.0f,
+
+ // Batch 0, Channel 1, Height (2) x Width (2)
+ 2.0f, 5.0f,
+ 8.0f, 11.0f,
+
+ // Batch 0, Channel 2, Height (2) x Width (2)
+ 3.0f, 6.0f,
+ 9.0f, 12.0f,
+ });
+
+ std::vector<unsigned int> blockShape({2, 2});
+ std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
+
+ return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager,
+ armnn::DataLayout::NCHW, inputShape, input, blockShape,
+ crops, outputShape, expectedOutput);
+}
+
+template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
+LayerTestResult<T, 4> BatchToSpaceNdNchwTest2(
+ armnn::IWorkloadFactory& workloadFactory,
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+{
+ const unsigned int inputShape[] = {4, 1, 1, 1};
+ const unsigned int outputShape[] = {1, 1, 2, 2};
+
+ std::vector<float> input({
+ // Batch 0, Height 0, Width (2) x Channel (1)
+ 1.0f, 2.0f, 3.0f, 4.0f
+ });
+
+ std::vector<float> expectedOutput({1.0f, 2.0f, 3.0f, 4.0f});
+
+ std::vector<unsigned int> blockShape({2, 2});
+ std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
+
+ return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager,
+ armnn::DataLayout::NCHW, inputShape, input, blockShape,
+ crops, outputShape, expectedOutput);
+}
+
+template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
+LayerTestResult<T, 4> BatchToSpaceNdNchwTest3(
+ armnn::IWorkloadFactory& workloadFactory,
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+{
+ const unsigned int inputShape[] = {4, 3, 1, 1};
+ const unsigned int outputShape[] = {1, 3, 2, 2};
+
+ 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});
+
+ std::vector<float> expectedOutput({
+ // Batch 0, Channel 0, Height (2) x Width (2)
+ 1.0f, 7.0f,
+ 2.0f, 8.0f,
+
+ // Batch 0, Channel 1, Height (2) x Width (2)
+ 3.0f, 9.0f,
+ 4.0f, 10.0f,
+
+ // Batch 0, Channel 2, Height (2) x Width (2)
+ 5.0f, 11.0f,
+ 6.0f, 12.0f,
+ });
+
+ std::vector<unsigned int> blockShape({2, 2});
+ std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
+
+ return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager,
+ armnn::DataLayout::NCHW, inputShape, input, blockShape,
+ crops, outputShape, expectedOutput);
+}
+
+template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
+LayerTestResult<T, 4> BatchToSpaceNdNchwTest4(
+ armnn::IWorkloadFactory &workloadFactory,
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+{
+ const unsigned int inputShape[] = {4, 3, 1, 1};
+ const unsigned int outputShape[] = {1, 3, 2, 2};
+
+ std::vector<float> input({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
+
+ std::vector<float> expectedOutput({
+ // Batch 0, Channel 0, Height (2) x Width (2)
+ 1, 4,
+ 7, 10,
+
+ // Batch 0, Channel 1, Height (2) x Width (2)
+ 2, 5,
+ 8, 11,
+
+ // Batch 0, Channel 2, Height (2) x Width (2)
+ 3, 6,
+ 9, 12,
+ });
+
+ std::vector<unsigned int> blockShape({2, 2});
+ std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
+
+ return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager,
+ armnn::DataLayout::NCHW, inputShape, input, blockShape,
+ crops, outputShape, expectedOutput);
+}
+
+template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
+LayerTestResult<T, 4> BatchToSpaceNdNchwTest5(
+ armnn::IWorkloadFactory& workloadFactory,
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+{
+ const unsigned int inputShape[] = {4, 1, 1, 1};
+ const unsigned int outputShape[] = {1, 1, 2, 2};
+
+ std::vector<float> input({
+ // Batch 0, Height 0, Width (2) x Channel (1)
+ 1, 2, 3, 4
+ });
+
+ std::vector<float> expectedOutput({1, 2, 3, 4});
+
+ std::vector<unsigned int> blockShape({2, 2});
+ std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
+
+ return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager,
+ armnn::DataLayout::NCHW, inputShape, input, blockShape,
+ crops, outputShape, expectedOutput);
+}
+
+template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
+LayerTestResult<T, 4> BatchToSpaceNdNchwTest6(
+ armnn::IWorkloadFactory& workloadFactory,
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+{
+ const unsigned int inputShape[] = {4, 3, 1, 1};
+ const unsigned int outputShape[] = {1, 3, 2, 2};
+
+ std::vector<float> input({1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10, 12});
+
+ std::vector<float> expectedOutput({
+ // Batch 0, Channel 0, Height (2) x Width (2)
+ 1, 7,
+ 2, 8,
+
+ // Batch 0, Channel 1, Height (2) x Width (2)
+ 3, 9,
+ 4, 10,
+
+ // Batch 0, Channel 2, Height (2) x Width (2)
+ 5, 11,
+ 6, 12,
+ });
+
+ std::vector<unsigned int> blockShape({2, 2});
+ std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
+
+ return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager,
+ armnn::DataLayout::NCHW, inputShape, input, blockShape,
+ crops, outputShape, expectedOutput);
+}
+
+template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
+LayerTestResult<T, 4> BatchToSpaceNdNchwTest7(
+ armnn::IWorkloadFactory& workloadFactory,
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+{
+ const unsigned int inputShape[] = {8, 1, 1, 3};
+ const unsigned int outputShape[] = {2, 1, 2, 4};
+
+ std::vector<float> input({
+ 0, 1, 3, 0, 9, 11,
+ 0, 2, 4, 0, 10, 12,
+ 0, 5, 7, 0, 13, 15,
+ 0, 6, 8, 0, 14, 16
+ });
+
+ std::vector<float> expectedOutput({
+ 1, 2, 3, 4,
+ 5, 6, 7, 8,
+ 9, 10, 11, 12,
+ 13, 14, 15, 16
+ });
+
+ std::vector<unsigned int> blockShape({2, 2});
+ std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {2, 0}};
+
+ return BatchToSpaceNdHelper<ArmnnType, 4, 4>(workloadFactory, memoryManager,
+ armnn::DataLayout::NCHW, inputShape, input, blockShape,
+ crops, outputShape, expectedOutput);
+}
+
template LayerTestResult<typename armnn::ResolveType<armnn::DataType::Float32>, 4>
PreluTest<armnn::DataType::Float32>(
armnn::IWorkloadFactory& workloadFactory,
diff --git a/src/backends/cl/test/ClLayerTests.cpp b/src/backends/cl/test/ClLayerTests.cpp
index 0d6f4d3785..db6bd82a9a 100644
--- a/src/backends/cl/test/ClLayerTests.cpp
+++ b/src/backends/cl/test/ClLayerTests.cpp
@@ -41,21 +41,21 @@ ARMNN_AUTO_TEST_CASE(Logistic, SimpleSigmoidTest)
ARMNN_AUTO_TEST_CASE(LogisticUint8, SimpleSigmoidUint8Test)
// Batch To Space
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat321, BatchToSpaceNdNhwcFloat32Test1)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat322, BatchToSpaceNdNhwcFloat32Test2)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat323, BatchToSpaceNdNhwcFloat32Test3)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat321, BatchToSpaceNdNhwcTest1<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat322, BatchToSpaceNdNhwcTest2<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat323, BatchToSpaceNdNhwcTest3<armnn::DataType::Float32>)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat321, BatchToSpaceNdNchwFloat32Test1)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat322, BatchToSpaceNdNchwFloat32Test2)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat323, BatchToSpaceNdNchwFloat32Test3)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat321, BatchToSpaceNdNchwTest1<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat322, BatchToSpaceNdNchwTest2<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat323, BatchToSpaceNdNchwTest3<armnn::DataType::Float32>)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint1, BatchToSpaceNdNhwcUintTest1)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint2, BatchToSpaceNdNhwcUintTest2)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint3, BatchToSpaceNdNhwcUintTest3)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint1, BatchToSpaceNdNhwcTest1<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint2, BatchToSpaceNdNhwcTest2<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint3, BatchToSpaceNdNhwcTest3<armnn::DataType::QuantisedAsymm8>)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint1, BatchToSpaceNdNchwUintTest1)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint2, BatchToSpaceNdNchwUintTest2)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint3, BatchToSpaceNdNchwUintTest3)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint1, BatchToSpaceNdNchwTest1<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint2, BatchToSpaceNdNchwTest2<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint3, BatchToSpaceNdNchwTest3<armnn::DataType::QuantisedAsymm8>)
// Fully Connected
ARMNN_AUTO_TEST_CASE(SimpleFullyConnected, FullyConnectedFloat32Test, false, false)
diff --git a/src/backends/reference/test/RefCreateWorkloadTests.cpp b/src/backends/reference/test/RefCreateWorkloadTests.cpp
index d174093fd4..67b1d945db 100644
--- a/src/backends/reference/test/RefCreateWorkloadTests.cpp
+++ b/src/backends/reference/test/RefCreateWorkloadTests.cpp
@@ -691,6 +691,29 @@ BOOST_AUTO_TEST_CASE(CreateRsqrtQsymm16)
RefCreateRsqrtTest<RefRsqrtWorkload, armnn::DataType::QuantisedSymm16>();
}
+template <typename BatchToSpaceNdWorkloadType, armnn::DataType DataType>
+static void RefCreateBatchToSpaceNdTest()
+{
+ Graph graph;
+ RefWorkloadFactory factory;
+
+ auto workload = CreateBatchToSpaceNdWorkloadTest<BatchToSpaceNdWorkloadType, DataType>(factory, graph);
+
+ CheckInputOutput(std::move(workload),
+ TensorInfo({ 1, 1 }, DataType),
+ TensorInfo({ 1, 1 }, DataType));
+}
+
+BOOST_AUTO_TEST_CASE(CreateBatchToSpaceNdFloat32)
+{
+ RefCreateBatchToSpaceNdTest<RefBatchToSpaceNdWorkload, armnn::DataType::Float32>();
+}
+
+BOOST_AUTO_TEST_CASE(CreateBatchToSpaceNdUint8)
+{
+ RefCreateBatchToSpaceNdTest<RefBatchToSpaceNdWorkload, armnn::DataType::QuantisedAsymm8>();
+}
+
template <typename L2NormalizationWorkloadType, armnn::DataType DataType>
static void RefCreateL2NormalizationTest(DataLayout dataLayout)
{
diff --git a/src/backends/reference/test/RefLayerTests.cpp b/src/backends/reference/test/RefLayerTests.cpp
index 9cb8d13adc..4cb261f07d 100644
--- a/src/backends/reference/test/RefLayerTests.cpp
+++ b/src/backends/reference/test/RefLayerTests.cpp
@@ -811,24 +811,40 @@ ARMNN_AUTO_TEST_CASE(SpaceToBatchNdMultiChannelsNHWCUint16, SpaceToBatchNdMultiC
ARMNN_AUTO_TEST_CASE(SpaceToBatchNdMultiBlockNHWCUint16, SpaceToBatchNdMultiBlockNHWCUint16Test)
ARMNN_AUTO_TEST_CASE(SpaceToBatchNdPaddingNHWCUint16, SpaceToBatchNdPaddingNHWCUint16Test)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat321, BatchToSpaceNdNhwcFloat32Test1)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat322, BatchToSpaceNdNhwcFloat32Test2)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat323, BatchToSpaceNdNhwcFloat32Test3)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat324, BatchToSpaceNdNhwcFloat32Test4)
-
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat321, BatchToSpaceNdNchwFloat32Test1)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat322, BatchToSpaceNdNchwFloat32Test2)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat323, BatchToSpaceNdNchwFloat32Test3)
-
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint1, BatchToSpaceNdNhwcUintTest1)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint2, BatchToSpaceNdNhwcUintTest2)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint3, BatchToSpaceNdNhwcUintTest3)
-
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint1, BatchToSpaceNdNchwUintTest1)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint2, BatchToSpaceNdNchwUintTest2)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint3, BatchToSpaceNdNchwUintTest3)
-ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint4, BatchToSpaceNdNchwUintTest4)
-
+// BatchToSpace
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat1, BatchToSpaceNdNhwcTest1<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat2, BatchToSpaceNdNhwcTest2<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat3, BatchToSpaceNdNhwcTest3<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat4, BatchToSpaceNdNhwcTest4<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat5, BatchToSpaceNdNhwcTest5<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat6, BatchToSpaceNdNhwcTest6<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcFloat7, BatchToSpaceNdNhwcTest7<armnn::DataType::Float32>)
+
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint1, BatchToSpaceNdNhwcTest1<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint2, BatchToSpaceNdNhwcTest2<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint3, BatchToSpaceNdNhwcTest3<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint4, BatchToSpaceNdNhwcTest4<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint5, BatchToSpaceNdNhwcTest5<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint6, BatchToSpaceNdNhwcTest6<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint7, BatchToSpaceNdNhwcTest7<armnn::DataType::QuantisedAsymm8>)
+
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat1, BatchToSpaceNdNchwTest1<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat2, BatchToSpaceNdNchwTest2<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat3, BatchToSpaceNdNchwTest3<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat4, BatchToSpaceNdNchwTest4<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat5, BatchToSpaceNdNchwTest5<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat6, BatchToSpaceNdNchwTest6<armnn::DataType::Float32>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat7, BatchToSpaceNdNchwTest7<armnn::DataType::Float32>)
+
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint1, BatchToSpaceNdNchwTest1<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint2, BatchToSpaceNdNchwTest2<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint3, BatchToSpaceNdNchwTest3<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint4, BatchToSpaceNdNchwTest4<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint5, BatchToSpaceNdNchwTest5<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint6, BatchToSpaceNdNchwTest6<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint7, BatchToSpaceNdNchwTest7<armnn::DataType::QuantisedAsymm8>)
+
+// SpaceToDepth
ARMNN_AUTO_TEST_CASE(SpaceToDepthNCHWAsymmQ8, SpaceToDepthNCHWAsymmQ8Test)
ARMNN_AUTO_TEST_CASE(SpaceToDepthNHWCAsymmQ8, SpaceToDepthNHWCAsymmQ8Test)