From 595408218a0e17f04d91ff131a8227a4f352ff61 Mon Sep 17 00:00:00 2001 From: James Conroy Date: Thu, 11 Oct 2018 12:39:05 +0100 Subject: IVGCVSW-1978: Support NHWC for ResizeBilinear CpuRef * Adds implementation to plumb DataLayout parameter for ResizeBilinear on CpuRef. * Adds unit tests to execute ResizeBilinear on CpuRef using the NHWC data layout. * Adds DataLayoutIndexed API, allowing easy access to the Channels, Height and Width of a tensor based on its data layout. This reduces code duplication. * Refactors original ResizeBilinear implementation and tests to use the DataLayoutIndexed API when required. Change-Id: Ic2b8916cdd2e370d070175547079d774daf6d7bf --- .../reference/test/RefCreateWorkloadTests.cpp | 33 +++++++++++++++++----- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'src/backends/reference/test/RefCreateWorkloadTests.cpp') diff --git a/src/backends/reference/test/RefCreateWorkloadTests.cpp b/src/backends/reference/test/RefCreateWorkloadTests.cpp index e88fbed014..e8d536f6e8 100644 --- a/src/backends/reference/test/RefCreateWorkloadTests.cpp +++ b/src/backends/reference/test/RefCreateWorkloadTests.cpp @@ -420,27 +420,46 @@ BOOST_AUTO_TEST_CASE(CreateSingleOutputMultipleInputsUint8) } template -static void RefCreateResizeBilinearTest() +static void RefCreateResizeBilinearTest(DataLayout dataLayout) { Graph graph; RefWorkloadFactory factory; - auto workload = CreateResizeBilinearWorkloadTest(factory, graph); + auto workload = CreateResizeBilinearWorkloadTest(factory, graph, dataLayout); + + TensorShape inputShape; + TensorShape outputShape; + + switch (dataLayout) + { + case DataLayout::NHWC: + inputShape = { 2, 4, 4, 3 }; + outputShape = { 2, 2, 2, 3 }; + break; + default: // NCHW + inputShape = { 2, 3, 4, 4 }; + outputShape = { 2, 3, 2, 2 }; + } // Checks that outputs and inputs are as we expect them (see definition of CreateResizeBilinearWorkloadTest). CheckInputOutput( - std::move(workload), - TensorInfo({ 2, 3, 4, 4 }, DataType), - TensorInfo({ 2, 3, 2, 2 }, DataType)); + std::move(workload), + TensorInfo(inputShape, DataType), + TensorInfo(outputShape, DataType)); } BOOST_AUTO_TEST_CASE(CreateResizeBilinearFloat32) { - RefCreateResizeBilinearTest(); + RefCreateResizeBilinearTest(DataLayout::NCHW); } BOOST_AUTO_TEST_CASE(CreateResizeBilinearUint8) { - RefCreateResizeBilinearTest(); + RefCreateResizeBilinearTest(DataLayout::NCHW); +} + +BOOST_AUTO_TEST_CASE(CreateResizeBilinearFloat32Nhwc) +{ + RefCreateResizeBilinearTest(DataLayout::NHWC); } BOOST_AUTO_TEST_CASE(CreateL2NormalizationFloat32) -- cgit v1.2.1