From ad7515d231acb075a9585e52f257373b1a1b5d1f Mon Sep 17 00:00:00 2001 From: Michalis Spyrou Date: Fri, 24 Jul 2020 00:02:23 +0100 Subject: COMPMID-3385: Async support to CLArithmetic* kernels/functions Pt.1 Signed-off-by: Michalis Spyrou Change-Id: I94007565e688f8a0aead4f14c9fc30bfd9f9f7eb Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3613 Tested-by: Arm Jenkins Reviewed-by: Georgios Pinitas --- arm_compute/runtime/CL/functions/CLPReluLayer.h | 65 +++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 3 deletions(-) (limited to 'arm_compute/runtime/CL/functions/CLPReluLayer.h') diff --git a/arm_compute/runtime/CL/functions/CLPReluLayer.h b/arm_compute/runtime/CL/functions/CLPReluLayer.h index eb3d3be3e3..08567cccfb 100644 --- a/arm_compute/runtime/CL/functions/CLPReluLayer.h +++ b/arm_compute/runtime/CL/functions/CLPReluLayer.h @@ -24,20 +24,72 @@ #ifndef ARM_COMPUTE_CLPRELULAYER_H #define ARM_COMPUTE_CLPRELULAYER_H -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/ICLSimpleFunction.h" +#include "arm_compute/core/CL/kernels/CLFillBorderKernel.h" +#include "arm_compute/runtime/CL/ICLOperator.h" +#include "arm_compute/runtime/IFunction.h" namespace arm_compute { class ICLTensor; +namespace experimental +{ /** Basic function to run @ref CLArithmeticOperationKernel for PRELU * * @note The function implements an activation layer with the PRELU activation function. */ -class CLPReluLayer : public ICLSimpleFunction +class CLPReluLayer : public ICLOperator { public: + /** Default Constructor */ + CLPReluLayer(); + /** Set the input and output tensor. + * + * @note If the output tensor is a nullptr or is equal to the input, the activation function will be performed in-place + * + * @param[in] compile_context The compile context to be used. + * @param[in] input Source tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32. + * @param[in] alpha PRelu layer parameters. Data types supported: same of @p input. + * @param[out] output Destination tensor. Data type supported: same as @p input + */ + void configure(const CLCompileContext &compile_context, ITensorInfo *input, ITensorInfo *alpha, ITensorInfo *output); + /** Static function to check if given info will lead to a valid configuration of @ref CLPReluLayer + * + * @param[in] input Source tensor info. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32. + * @param[in] alpha PRelu layer parameters. Data types supported: same of @p input. + * @param[in] output Destination tensor info. Data type supported: same as @p input + * + * @return a status + */ + static Status validate(const ITensorInfo *input, const ITensorInfo *alpha, const ITensorInfo *output); + + // Inherited methods overridden: + void run(InputTensorMap inputs, OutputTensorMap outputs, OperatorTensorMap workspace) override; + +private: + CLFillBorderKernel _border_handler; +}; +} // namespace experimental + +/** Basic function to run @ref CLArithmeticOperationKernel for PRELU + * + * @note The function implements an activation layer with the PRELU activation function. + */ +class CLPReluLayer : public IFunction +{ +public: + /** Default Constructor */ + CLPReluLayer(); + /** Default Destructor */ + ~CLPReluLayer(); + /** Prevent instances of this class from being copied (As this class contains pointers) */ + CLPReluLayer(const CLPReluLayer &) = delete; + /** Default move constructor */ + CLPReluLayer(CLPReluLayer &&); + /** Prevent instances of this class from being copied (As this class contains pointers) */ + CLPReluLayer &operator=(const CLPReluLayer &) = delete; + /** Default move assignment operator */ + CLPReluLayer &operator=(CLPReluLayer &&); /** Set the input and output tensor. * * @note If the output tensor is a nullptr or is equal to the input, the activation function will be performed in-place @@ -66,6 +118,13 @@ public: * @return a status */ static Status validate(const ITensorInfo *input, const ITensorInfo *alpha, const ITensorInfo *output); + + // Inherited methods overridden: + void run() override; + +private: + struct Impl; + std::unique_ptr _impl; }; } // namespace arm_compute #endif /* ARM_COMPUTE_CLPRELULAYER_H */ -- cgit v1.2.1