From e74b201ca1abca040ca9f30837fdf19aa610e7c4 Mon Sep 17 00:00:00 2001 From: Michalis Spyrou Date: Wed, 18 Apr 2018 09:49:16 +0100 Subject: COMPMID-805 Add NHWC data format support for CL pooling Change-Id: I3d91fde78b971aba3f6349f633cd9b1c50e5cacf Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/124712 Reviewed-by: Gian Marco Iodice Tested-by: Jenkins Reviewed-by: Georgios Pinitas --- src/runtime/CL/functions/CLPoolingLayer.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/runtime/CL/functions/CLPoolingLayer.cpp') diff --git a/src/runtime/CL/functions/CLPoolingLayer.cpp b/src/runtime/CL/functions/CLPoolingLayer.cpp index 201bf87b47..17875a38ad 100644 --- a/src/runtime/CL/functions/CLPoolingLayer.cpp +++ b/src/runtime/CL/functions/CLPoolingLayer.cpp @@ -41,13 +41,28 @@ void CLPoolingLayer::configure(ICLTensor *input, ICLTensor *output, const Poolin _kernel = std::move(k); // Configure border depending on operation required (quantize border in case of asymmetric data_type) - BorderMode border_mode = (PoolingType::MAX == pool_info.pool_type()) ? BorderMode::REPLICATE : BorderMode::CONSTANT; - PixelValue zero_value(0.f); + BorderMode border_mode{}; + PixelValue pixel_value(0.f); if(is_data_type_quantized_asymmetric(input->info()->data_type()) && !pool_info.exclude_padding()) { - zero_value = PixelValue(static_cast(input->info()->quantization_info().offset)); + pixel_value = PixelValue(static_cast(input->info()->quantization_info().offset)); } - _border_handler.configure(input, _kernel->border_size(), border_mode, zero_value); + switch(input->info()->data_layout()) + { + case DataLayout::NCHW: + border_mode = (PoolingType::MAX == pool_info.pool_type()) ? BorderMode::REPLICATE : BorderMode::CONSTANT; + break; + case DataLayout::NHWC: + border_mode = BorderMode::CONSTANT; + if(PoolingType::MAX == pool_info.pool_type() && !is_data_type_quantized_asymmetric(input->info()->data_type())) + { + pixel_value = PixelValue(std::numeric_limits::lowest()); + } + break; + default: + ARM_COMPUTE_ERROR("Data layout not supported"); + } + _border_handler.configure(input, _kernel->border_size(), border_mode, pixel_value); } Status CLPoolingLayer::validate(const ITensorInfo *input, const ITensorInfo *output, const PoolingLayerInfo &pool_info) -- cgit v1.2.1