From 8eb82d235f605cd07220107588dde54c704f61a6 Mon Sep 17 00:00:00 2001 From: Viet-Hoa Do Date: Wed, 21 Jun 2023 10:39:48 +0100 Subject: Fix CPU depthwise convolution in case of large padding * Avoid the assembly kernels to be used when the padding is greater than the kernel shape. Resolves: COMPMID-6280 Signed-off-by: Viet-Hoa Do Change-Id: Ibe0820018c97f4481bf318397b797ec7b351a1d5 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9802 Benchmark: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Jakub Sujak Comments-Addressed: Arm Jenkins --- docs/user_guide/release_version_and_change_log.dox | 1 + .../internal/CpuDepthwiseConv2dAssemblyWrapperKernel.cpp | 10 ++++++++++ tests/datasets/DepthwiseConvolutionLayerDataset.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/docs/user_guide/release_version_and_change_log.dox b/docs/user_guide/release_version_and_change_log.dox index 04baaf57fa..639f6f6c8b 100644 --- a/docs/user_guide/release_version_and_change_log.dox +++ b/docs/user_guide/release_version_and_change_log.dox @@ -43,6 +43,7 @@ If there is more than one release in a month then an extra sequential number is v23.08 Public major release - Deprecate the legacy 'libarm_compute_core' library. This library is an artifact of Compute Library's legacy library architecture and no longer serves any purpose. Users must no longer link their applications to this library and instead link only to the main `libarm_compute` library for core functionality. + - Various optimizations and bug fixes. v23.05 Public major release - New features: diff --git a/src/cpu/kernels/internal/CpuDepthwiseConv2dAssemblyWrapperKernel.cpp b/src/cpu/kernels/internal/CpuDepthwiseConv2dAssemblyWrapperKernel.cpp index 5360abf5ac..8cda5c6afd 100644 --- a/src/cpu/kernels/internal/CpuDepthwiseConv2dAssemblyWrapperKernel.cpp +++ b/src/cpu/kernels/internal/CpuDepthwiseConv2dAssemblyWrapperKernel.cpp @@ -303,6 +303,16 @@ Status CpuDepthwiseConv2dAssemblyWrapperKernel::validate(const ITensorInfo *src, ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(dst->tensor_shape(), dst_shape); ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst); } + + // Assembly kernels cannot work with padding greater than the kernel. + const auto &padding = info.pad_stride_info; + const auto &wei_shape = weights->tensor_shape(); + + ARM_COMPUTE_RETURN_ERROR_ON( + padding.pad_top() >= wei_shape[2] || padding.pad_bottom() >= wei_shape[2] || + padding.pad_left() >= wei_shape[1] || padding.pad_right() >= wei_shape[1] + ); + return Status{}; } diff --git a/tests/datasets/DepthwiseConvolutionLayerDataset.h b/tests/datasets/DepthwiseConvolutionLayerDataset.h index d0e8efcde5..f88cb887fc 100644 --- a/tests/datasets/DepthwiseConvolutionLayerDataset.h +++ b/tests/datasets/DepthwiseConvolutionLayerDataset.h @@ -152,6 +152,8 @@ public: add_config(TensorShape(33U, 27U, 7U), Size2D(5U, 7U), PadStrideInfo(3, 2, 1, 3, 0, 2, DimensionRoundingType::FLOOR)); add_config(TensorShape(33U, 27U, 7U), Size2D(5U, 7U), PadStrideInfo(3, 2, 1, 0, 1, 0, DimensionRoundingType::FLOOR)); add_config(TensorShape(33U, 27U, 7U), Size2D(5U, 7U), PadStrideInfo(3, 2, 0, 1, 0, 1, DimensionRoundingType::FLOOR)); + // Padding greater than kernel size. + add_config(TensorShape(128, 56, 56), Size2D(4, 4), PadStrideInfo(2, 2, 0, 10, 0, 10, DimensionRoundingType::FLOOR)); } }; -- cgit v1.2.1