From bae22373a71ccf9b4c008e62f081344a929ffb24 Mon Sep 17 00:00:00 2001 From: Michele Di Giorgio Date: Fri, 12 Feb 2021 17:34:17 +0000 Subject: Fix data layout retention and handling of leftovers when there is no padding Resolves COMPMID-4258 Change-Id: I8782bf725cd0d376d538021406eb1f5be962b2cb Signed-off-by: Michele Di Giorgio Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/c/VisualCompute/ComputeLibrary/+/298627 Reviewed-by: Teresa Charlin Reyes Reviewed-by: Georgios Pinitas Comments-Addressed: Teresa Charlin Reyes Tested-by: Georgios Pinitas Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5082 Reviewed-by: TeresaARM --- .../arm_conv/pooling/pooling_depthfirst_generic.hpp | 17 ++++++++++++++++- .../pooling/pooling_depthfirst_generic_quantized.hpp | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'src/core/NEON/kernels/arm_conv/pooling') diff --git a/src/core/NEON/kernels/arm_conv/pooling/pooling_depthfirst_generic.hpp b/src/core/NEON/kernels/arm_conv/pooling/pooling_depthfirst_generic.hpp index fa06a0078b..5979862ed8 100644 --- a/src/core/NEON/kernels/arm_conv/pooling/pooling_depthfirst_generic.hpp +++ b/src/core/NEON/kernels/arm_conv/pooling/pooling_depthfirst_generic.hpp @@ -191,6 +191,13 @@ class PoolingDepthfirstGeneric : public PoolingCommon(std::max(end_in_i - height, 0)); const auto valid_rows = input_rows() - pad_top - pad_bottom; + // Compute the number of pooling window rows which are contained in + // either the valid region of the input tensor, or the padding. + const auto padded_bottom = std::min( + start_in_i + m_args.pool_window.rows, height + padding.bottom + ); + const auto n_total_rows = padded_bottom - start_in_i; + auto outptr_col = outptr_row; auto inptr_row = inptr_batch + (start_in_i + pad_top) * ld_input_row; @@ -205,6 +212,13 @@ class PoolingDepthfirstGeneric : public PoolingCommon(std::max(0, end_in_j - width)); const auto valid_cols = input_cols() - pad_left - pad_right; + // Compute the number of pooling window columns which are contained + // in either the valid region of the input tensor, or the padding. + const auto padded_right = std::min( + start_in_j + m_args.pool_window.cols, width + padding.right + ); + const auto n_total_cols = padded_right - start_in_j; + // Construct the input pointer array - fill in all valid points // contiguously. const TInput **ptrs = inptr_array; @@ -222,7 +236,8 @@ class PoolingDepthfirstGeneric : public PoolingCommon(-std::min(start_in_i, 0)); const auto pad_bottom = static_cast(-std::min(static_cast(height) - end_in_i, 0)); + // Compute the number of pooling window rows which are contained in + // either the valid region of the input tensor, or the padding. + const auto padded_bottom = std::min( + start_in_i + m_args.pool_window.rows, height + padding.bottom + ); + const auto n_total_rows = padded_bottom - start_in_i; + for (int out_j = 0, start_in_j = -padding.left; out_j < static_cast(output_width); out_j++, start_in_j += m_args.pool_stride.cols) @@ -201,6 +208,13 @@ class PoolingDepthfirstGenericQuantized : public PoolingCommon(-std::min(start_in_j, 0)); const auto pad_right = static_cast(-std::min(static_cast(width) - end_in_j, 0)); + // Compute the number of pooling window columns which are contained + // in either the valid region of the input tensor, or the padding. + const auto padded_right = std::min( + start_in_j + m_args.pool_window.cols, width + padding.right + ); + const auto n_total_cols = padded_right - start_in_j; + // Construct the input pointer array - fill in all valid points // contiguously. const TInput **ptrs = inptr_array; @@ -221,7 +235,8 @@ class PoolingDepthfirstGenericQuantized : public PoolingCommon