From afcbb8f47427405a35be508425376286f0fd7a70 Mon Sep 17 00:00:00 2001 From: Freddie Liardet Date: Tue, 4 May 2021 12:41:16 +0100 Subject: Fix Pooling Layer Bug when input is 1xN size Return error in pooling layer when any calculated output dimension is less than 1. Simplify use of pooling layer output dimension values in CpuPoolingKernel.cpp. Remove some invalid tests in cpu/gpu pooling layers. Resolves COMPMID-4358. Signed-off-by: Freddie Liardet Change-Id: If8f8ffec579d3eca1c27a45e5b0b684a77103cff Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5559 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins --- src/core/Utils.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/core/Utils.cpp') diff --git a/src/core/Utils.cpp b/src/core/Utils.cpp index e44c86db88..b81b498ae5 100644 --- a/src/core/Utils.cpp +++ b/src/core/Utils.cpp @@ -426,6 +426,35 @@ std::pair scaled_dimensions(int width, int height, return std::make_pair(static_cast(w), static_cast(h)); } +std::pair scaled_dimensions_signed(int width, int height, + int kernel_width, int kernel_height, + const PadStrideInfo &pad_stride_info) +{ + const int pad_left = pad_stride_info.pad_left(); + const int pad_top = pad_stride_info.pad_top(); + const int pad_right = pad_stride_info.pad_right(); + const int pad_bottom = pad_stride_info.pad_bottom(); + const int stride_x = pad_stride_info.stride().first; + const int stride_y = pad_stride_info.stride().second; + int w = 0; + int h = 0; + switch(pad_stride_info.round()) + { + case DimensionRoundingType::FLOOR: + w = static_cast(std::floor((static_cast(width + pad_left + pad_right - kernel_width) / stride_x) + 1)); + h = static_cast(std::floor((static_cast(height + pad_top + pad_bottom - kernel_height) / stride_y) + 1)); + break; + case DimensionRoundingType::CEIL: + w = static_cast(std::ceil((static_cast(width + pad_left + pad_right - kernel_width) / stride_x) + 1)); + h = static_cast(std::ceil((static_cast(height + pad_top + pad_bottom - kernel_height) / stride_y) + 1)); + break; + default: + ARM_COMPUTE_ERROR("Unsupported rounding type"); + } + + return std::make_pair(static_cast(w), static_cast(h)); +} + bool needs_serialized_reduction(ReductionOperation op, DataType dt, unsigned int axis) { const bool is_min_max = (op == ReductionOperation::MAX || op == ReductionOperation::MIN); -- cgit v1.2.1