diff options
author | Jaroslaw Rzepecki <jaroslaw.rzepecki@arm.com> | 2017-10-13 11:13:58 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | a1ed41fe2427dfa2b5d0139444ceb77ad16a5a73 (patch) | |
tree | a57bc2369afea73c190d9bb595b0a229bf8da749 /src/core/Utils.cpp | |
parent | b4276c5b76f6eda22d973bfa48ff9612e7f183e5 (diff) | |
download | ComputeLibrary-a1ed41fe2427dfa2b5d0139444ceb77ad16a5a73.tar.gz |
IVGCVSW-601: support for asymetric padding in cl conv and depthwise conv
Change-Id: I5c6c95091ae77dba96459c0640f9f6167a988c8c
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/91700
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'src/core/Utils.cpp')
-rw-r--r-- | src/core/Utils.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/core/Utils.cpp b/src/core/Utils.cpp index d5ce1ea027..0a35e07430 100644 --- a/src/core/Utils.cpp +++ b/src/core/Utils.cpp @@ -288,37 +288,39 @@ const std::pair<unsigned int, unsigned int> arm_compute::scaled_dimensions(unsig unsigned int kernel_width, unsigned int kernel_height, const PadStrideInfo &pad_stride_info) { - const unsigned int pad_x = pad_stride_info.pad().first; - const unsigned int pad_y = pad_stride_info.pad().second; - const unsigned int stride_x = pad_stride_info.stride().first; - const unsigned int stride_y = pad_stride_info.stride().second; - unsigned int w = 0; - unsigned int h = 0; + const unsigned int pad_left = pad_stride_info.pad_left(); + const unsigned int pad_top = pad_stride_info.pad_top(); + const unsigned int pad_right = pad_stride_info.pad_right(); + const unsigned int pad_bottom = pad_stride_info.pad_bottom(); + const unsigned int stride_x = pad_stride_info.stride().first; + const unsigned int stride_y = pad_stride_info.stride().second; + unsigned int w = 0; + unsigned int h = 0; switch(pad_stride_info.round()) { case DimensionRoundingType::FLOOR: - w = static_cast<unsigned int>(std::floor((static_cast<float>(width + 2 * pad_x - kernel_width) / stride_x) + 1)); - h = static_cast<unsigned int>(std::floor((static_cast<float>(height + 2 * pad_y - kernel_height) / stride_y) + 1)); + w = static_cast<unsigned int>(std::floor((static_cast<float>(width + pad_left + pad_right - kernel_width) / stride_x) + 1)); + h = static_cast<unsigned int>(std::floor((static_cast<float>(height + pad_top + pad_bottom - kernel_height) / stride_y) + 1)); break; case DimensionRoundingType::CEIL: - w = static_cast<unsigned int>(std::ceil((static_cast<float>(width + 2 * pad_x - kernel_width) / stride_x) + 1)); - h = static_cast<unsigned int>(std::ceil((static_cast<float>(height + 2 * pad_y - kernel_height) / stride_y) + 1)); + w = static_cast<unsigned int>(std::ceil((static_cast<float>(width + pad_left + pad_right - kernel_width) / stride_x) + 1)); + h = static_cast<unsigned int>(std::ceil((static_cast<float>(height + pad_top + pad_bottom - kernel_height) / stride_y) + 1)); break; default: ARM_COMPUTE_ERROR("Unsupported rounding type"); } // Make sure that border operations will start from inside the input and not the padded area - if(((w - 1) * stride_x) >= (width + pad_x)) + if(((w - 1) * stride_x) >= (width + pad_left)) { --w; } - if(((h - 1) * stride_y) >= (height + pad_y)) + if(((h - 1) * stride_y) >= (height + pad_top)) { --h; } - ARM_COMPUTE_ERROR_ON(((w - 1) * stride_x) >= (width + pad_x)); - ARM_COMPUTE_ERROR_ON(((h - 1) * stride_y) >= (height + pad_y)); + ARM_COMPUTE_ERROR_ON(((w - 1) * stride_x) >= (width + pad_left)); + ARM_COMPUTE_ERROR_ON(((h - 1) * stride_y) >= (height + pad_top)); return std::make_pair(w, h); } |