From 5c4a8e96460eb83a6caef1c69ea5cbb4893858d7 Mon Sep 17 00:00:00 2001 From: Giorgio Arena Date: Wed, 28 Aug 2019 17:55:07 +0100 Subject: COMPMID-2592 Create a new kernel for CLPad with SYMMETRIC and REFLECT mode Change-Id: Icaf0516f490b2ddca6d1ea03a5cf26cc7d43041f Signed-off-by: Giorgio Arena Reviewed-on: https://review.mlplatform.org/c/1872 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Gian Marco Iodice --- arm_compute/core/CL/kernels/CLPadLayerKernel.h | 5 ++--- arm_compute/runtime/CL/functions/CLPadLayer.h | 31 +++++++++----------------- 2 files changed, 12 insertions(+), 24 deletions(-) (limited to 'arm_compute') diff --git a/arm_compute/core/CL/kernels/CLPadLayerKernel.h b/arm_compute/core/CL/kernels/CLPadLayerKernel.h index 7e4b31cfda..ab6ad1762d 100644 --- a/arm_compute/core/CL/kernels/CLPadLayerKernel.h +++ b/arm_compute/core/CL/kernels/CLPadLayerKernel.h @@ -31,7 +31,7 @@ namespace arm_compute { class ICLTensor; -/** Interface for the PadLayer function. Only CONSTANT PaddingMode is currently supported*/ +/** Interface for the PadLayer function. */ class CLPadLayerKernel : public ICLKernel { public: @@ -56,7 +56,6 @@ public: * @param[in] constant_value (Optional) Constant value to be used for the padding. * @param[in] mode (Optional) Controls whether the padding should be filled with @p constant_value using CONSTANT, * or reflect the input, either including the border values (SYMMETRIC) or not (REFLECT). - * Only CONSTANT mode is currently supported. */ void configure(const ICLTensor *input, ICLTensor *output, const PaddingList &padding, PixelValue constant_value = PixelValue(), PaddingMode mode = PaddingMode::CONSTANT); /** Static function to check if given info will lead to a valid configuration of @ref CLPadLayerKernel @@ -68,7 +67,6 @@ public: * @param[in] constant_value (Optional) Constant value to be used for the padding. * @param[in] mode (Optional) Controls whether the padding should be filled with @p constant_value using CONSTANT, * or reflect the input, either including the border values (SYMMETRIC) or not (REFLECT). - * Only CONSTANT mode is currently supported. */ static Status validate(const ITensorInfo *input, const ITensorInfo *output, const PaddingList &padding, PixelValue constant_value = PixelValue(), PaddingMode mode = PaddingMode::CONSTANT); @@ -80,6 +78,7 @@ private: ICLTensor *_output; int _input_start_x; int _input_start_y; + bool _4d_enabled; }; } // namespace arm_compute #endif /*__ARM_COMPUTE_CLPADLAYERKERNEL_H__ */ diff --git a/arm_compute/runtime/CL/functions/CLPadLayer.h b/arm_compute/runtime/CL/functions/CLPadLayer.h index 58e0cabe63..fd801eae46 100644 --- a/arm_compute/runtime/CL/functions/CLPadLayer.h +++ b/arm_compute/runtime/CL/functions/CLPadLayer.h @@ -27,18 +27,16 @@ #include "arm_compute/core/CL/kernels/CLCopyKernel.h" #include "arm_compute/core/CL/kernels/CLPadLayerKernel.h" #include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/functions/CLConcatenateLayer.h" -#include "arm_compute/runtime/CL/functions/CLStridedSlice.h" +#include "arm_compute/runtime/IFunction.h" namespace arm_compute { class ICLTensor; -/** Basic function to pad a tensor. This function calls the following OpenCL kernels: +/** Basic function to pad a tensor. This function calls the following OpenCL functions/kernels: * - * -# @ref CLMemsetKernel - * -# @ref CLFillBorderKernel - * -# @ref CLCopyKernel + * -# @ref CLPadLayerKernel if there is padding to be added + * -# @ref CLCopyKernel otherwise */ class CLPadLayer : public IFunction { @@ -62,8 +60,7 @@ public: * specifies the front and the end padding in the i-th dimension. * @param[in] constant_value (Optional) Constant value to be used for the padding. * @param[in] mode (Optional) Controls whether the padding should be filled with @p constant_value using CONSTANT, - * or reflect the input, either including the border values (SYMMETRIC) or not (REFLECT). Only CONSTANT - * is currently supported. + * or reflect the input, either including the border values (SYMMETRIC) or not (REFLECT). */ void configure(ICLTensor *input, ICLTensor *output, const PaddingList &padding, PixelValue constant_value = PixelValue(), PaddingMode mode = PaddingMode::CONSTANT); @@ -75,8 +72,7 @@ public: * specifies the front and the end padding in the i-th dimension. * @param[in] constant_value (Optional) Constant value to be used for the padding * @param[in] mode (Optional) Controls whether the padding should be filled with @p constant_value using CONSTANT, - * or reflect the input, either including the border values (SYMMETRIC) or not (REFLECT). Only CONSTANT - * is currently supported. + * or reflect the input, either including the border values (SYMMETRIC) or not (REFLECT). */ static Status validate(const ITensorInfo *input, const ITensorInfo *output, const PaddingList &padding, PixelValue constant_value = PixelValue(), PaddingMode mode = PaddingMode::CONSTANT); @@ -84,18 +80,11 @@ public: void run() override; private: - void configure_constant_mode(ICLTensor *input, ICLTensor *output, const PaddingList &padding, const PixelValue constant_value); - void configure_reflect_symmetric_mode(ICLTensor *input, ICLTensor *output); + void configure_reflect_mode(ICLTensor *input, ICLTensor *output); - CLPadLayerKernel _pad_kernel; - CLCopyKernel _copy_kernel; - PaddingMode _mode; - PaddingList _padding; - size_t _num_dimensions; - std::vector _slice_functions; - std::vector _concat_functions; - std::vector _slice_results; - std::vector _concat_results; + CLPadLayerKernel _pad_kernel; + CLCopyKernel _copy_kernel; + bool _perform_pad; }; } // namespace arm_compute #endif /*__ARM_COMPUTE_PADLAYER_H__ */ -- cgit v1.2.1