From 69482271d3e02af950d2d0f1947ae6c3eeed537b Mon Sep 17 00:00:00 2001 From: James Conroy Date: Fri, 19 Oct 2018 10:41:35 +0100 Subject: IVGCVSW-2024: Support NHWC for Pooling2D CpuRef * Adds implementation to plumb DataLayout parameter for Pooling2D on CpuRef. * Adds unit tests to execute Pooling2D on CpuRef using NHWC data layout. * Refactors original tests to use DataLayoutIndexed and removes duplicate code. Change-Id: Ife7e0861a886cf58a2042e5be20e5b27af4528c9 --- src/backends/reference/workloads/Pooling2d.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/backends/reference/workloads') diff --git a/src/backends/reference/workloads/Pooling2d.cpp b/src/backends/reference/workloads/Pooling2d.cpp index 5812a290e7..9890920113 100644 --- a/src/backends/reference/workloads/Pooling2d.cpp +++ b/src/backends/reference/workloads/Pooling2d.cpp @@ -143,12 +143,16 @@ void Pooling2d(const float* in, const TensorInfo& outputInfo, const Pooling2dDescriptor& params) { + const unsigned int channelsIndex = params.m_DataLayout.GetChannelsIndex(); + const unsigned int heightIndex = params.m_DataLayout.GetHeightIndex(); + const unsigned int widthIndex = params.m_DataLayout.GetWidthIndex(); + const int batchSize = boost::numeric_cast(outputInfo.GetShape()[0]); - const int channels = boost::numeric_cast(outputInfo.GetShape()[1]); - const int heightOutput = boost::numeric_cast(outputInfo.GetShape()[2]); - const int widthOutput = boost::numeric_cast(outputInfo.GetShape()[3]); - const int heightInput = boost::numeric_cast(inputInfo.GetShape()[2]); - const int widthInput = boost::numeric_cast(inputInfo.GetShape()[3]); + const int channels = boost::numeric_cast(outputInfo.GetShape()[channelsIndex]); + const int heightOutput = boost::numeric_cast(outputInfo.GetShape()[heightIndex]); + const int widthOutput = boost::numeric_cast(outputInfo.GetShape()[widthIndex]); + const int heightInput = boost::numeric_cast(inputInfo.GetShape()[heightIndex]); + const int widthInput = boost::numeric_cast(inputInfo.GetShape()[widthIndex]); const int padLeft = boost::numeric_cast(params.m_PadLeft); const int padRight = boost::numeric_cast(params.m_PadRight); const int padTop = boost::numeric_cast(params.m_PadTop); -- cgit v1.2.1