aboutsummaryrefslogtreecommitdiff
path: root/src/core/Utils.cpp
diff options
context:
space:
mode:
authorFreddie Liardet <frederick.liardet@arm.com>2021-05-04 12:41:16 +0100
committerfrederick.liardet <frederick.liardet@arm.com>2021-05-13 13:13:06 +0000
commitafcbb8f47427405a35be508425376286f0fd7a70 (patch)
treeb373f2d2a6a94b53116c5a53da7c4b4181753486 /src/core/Utils.cpp
parentfd83bc8894007c2c9591896ba4229c99d8236a7a (diff)
downloadComputeLibrary-afcbb8f47427405a35be508425376286f0fd7a70.tar.gz
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 <frederick.liardet@arm.com> Change-Id: If8f8ffec579d3eca1c27a45e5b0b684a77103cff Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5559 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/Utils.cpp')
-rw-r--r--src/core/Utils.cpp29
1 files changed, 29 insertions, 0 deletions
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<unsigned int, unsigned int> scaled_dimensions(int width, int height,
return std::make_pair(static_cast<unsigned int>(w), static_cast<unsigned int>(h));
}
+std::pair<int, int> 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<int>(std::floor((static_cast<float>(width + pad_left + pad_right - kernel_width) / stride_x) + 1));
+ h = static_cast<int>(std::floor((static_cast<float>(height + pad_top + pad_bottom - kernel_height) / stride_y) + 1));
+ break;
+ case DimensionRoundingType::CEIL:
+ w = static_cast<int>(std::ceil((static_cast<float>(width + pad_left + pad_right - kernel_width) / stride_x) + 1));
+ h = static_cast<int>(std::ceil((static_cast<float>(height + pad_top + pad_bottom - kernel_height) / stride_y) + 1));
+ break;
+ default:
+ ARM_COMPUTE_ERROR("Unsupported rounding type");
+ }
+
+ return std::make_pair(static_cast<int>(w), static_cast<int>(h));
+}
+
bool needs_serialized_reduction(ReductionOperation op, DataType dt, unsigned int axis)
{
const bool is_min_max = (op == ReductionOperation::MAX || op == ReductionOperation::MIN);