From 074f371bcd1d91c1f36b458d9ea1b050eafe5947 Mon Sep 17 00:00:00 2001 From: James Conroy Date: Wed, 3 Oct 2018 09:32:03 +0100 Subject: IVGCVSW-1932: Add Unit tests for NHWC ResizeBilinear * Adds five unit tests that execute ResizeBilinear with the NHWC data layout and Float32 data type. * Refactors original ResizeBilinear Float32 tests to take DataLayout as a parameter. * Adds four unit tests that execute CreateWorkloadCl for both NCHW and NHWC (NCHW tests did not exist for CreateWorkloadCl). Change-Id: I1af419ed0b62b8f4d4550f6d120a584a0a223b17 --- src/armnn/test/CreateWorkload.hpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src/armnn/test') diff --git a/src/armnn/test/CreateWorkload.hpp b/src/armnn/test/CreateWorkload.hpp index 66f62820d9..f2c8b5a20a 100644 --- a/src/armnn/test/CreateWorkload.hpp +++ b/src/armnn/test/CreateWorkload.hpp @@ -807,13 +807,33 @@ void CreateSplitterMultipleInputsOneOutputWorkloadTest(armnn::IWorkloadFactory& template std::unique_ptr CreateResizeBilinearWorkloadTest(armnn::IWorkloadFactory& factory, - armnn::Graph& graph) + armnn::Graph& graph, + DataLayout dataLayout = DataLayout::NCHW) { + TensorShape inputShape; + TensorShape outputShape; + unsigned int heightIndex; + unsigned int widthIndex; + + switch (dataLayout) { + case DataLayout::NHWC: + inputShape = { 2, 4, 4, 3 }; + outputShape = { 2, 2, 2, 3 }; + heightIndex = 1; + widthIndex = 2; + break; + default: // NCHW + inputShape = { 2, 3, 4, 4 }; + outputShape = { 2, 3, 2, 2 }; + heightIndex = 2; + widthIndex = 3; + } + // Creates the layer we're testing. - TensorShape outputShape({ 2, 3, 2, 2 }); ResizeBilinearDescriptor resizeDesc; - resizeDesc.m_TargetWidth = outputShape[3]; - resizeDesc.m_TargetHeight = outputShape[2]; + resizeDesc.m_TargetWidth = outputShape[widthIndex]; + resizeDesc.m_TargetHeight = outputShape[heightIndex]; + resizeDesc.m_DataLayout = dataLayout; Layer* const layer = graph.AddLayer(resizeDesc, "layer"); // Creates extra layers. @@ -821,7 +841,7 @@ std::unique_ptr CreateResizeBilinearWorkloadTest(armnn:: Layer* const output = graph.AddLayer(0, "output"); // Connects up. - armnn::TensorInfo inputTensorInfo({ 2, 3, 4, 4 }, DataType); + armnn::TensorInfo inputTensorInfo(inputShape, DataType); armnn::TensorInfo outputTensorInfo(outputShape, DataType); Connect(input, layer, inputTensorInfo); Connect(layer, output, outputTensorInfo); @@ -833,6 +853,7 @@ std::unique_ptr CreateResizeBilinearWorkloadTest(armnn:: ResizeBilinearQueueDescriptor queueDescriptor = workload->GetData(); BOOST_TEST(queueDescriptor.m_Inputs.size() == 1); BOOST_TEST(queueDescriptor.m_Outputs.size() == 1); + BOOST_TEST((queueDescriptor.m_Parameters.m_DataLayout == dataLayout)); // Returns so we can do extra, backend-specific tests. return workload; -- cgit v1.2.1