From 7249f154c2ec029f9b8c91f2bb845abe6590f7ed Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Fri, 22 Jan 2021 11:55:03 +0000 Subject: Rename functions/classes for elementwise unary operations * Create CpuElementwiseUnary operator * Rename kernel classes * Make the kernels stateless Partially implements: COMPMID-4003 Change-Id: Ie0440cd01d4924847d6991b4df7ccaf311439297 Signed-off-by: Sang-Hoon Park Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4912 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins --- .../NEON/functions/NEElementwiseUnaryLayer.h | 162 +++++---------------- 1 file changed, 37 insertions(+), 125 deletions(-) (limited to 'arm_compute') diff --git a/arm_compute/runtime/NEON/functions/NEElementwiseUnaryLayer.h b/arm_compute/runtime/NEON/functions/NEElementwiseUnaryLayer.h index 46a7316705..e79e8696d9 100644 --- a/arm_compute/runtime/NEON/functions/NEElementwiseUnaryLayer.h +++ b/arm_compute/runtime/NEON/functions/NEElementwiseUnaryLayer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,151 +25,63 @@ #define ARM_COMPUTE_NEELEMENTWISEUNARYLAYER_H #include "arm_compute/core/Error.h" -#include "arm_compute/runtime/NEON/INESimpleFunctionNoBorder.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/IFunction.h" +#include "src/core/common/Macros.h" + +#include namespace arm_compute { class ITensor; class ITensorInfo; - -/** Basic function to perform inverse square root on an input tensor. */ -class NERsqrtLayer : public INESimpleFunctionNoBorder +/** Basic function to perform unary elementwise operations */ +template +class NEElementwiseUnaryLayer : public IFunction { public: - /** Initialize the function - * - * @param[in] input Input tensor. Data types supported: F16/F32. - * @param[out] output Output tensor. Data types supported: same as @p input. - */ - void configure(const ITensor *input, ITensor *output); - /** Static function to check if given info will lead to a valid configuration of @ref NERsqrtLayer - * - * @param[in] input First tensor input info. Data types supported: F16/F32. - * @param[in] output Output tensor info. Data types supported: Same as @p input. - * - * @return a status - */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output); -}; - -/** Basic function to perform exponential on an input tensor. */ -class NEExpLayer : public INESimpleFunctionNoBorder -{ -public: - /** Initialize the function - * - * @param[in] input Input tensor. Data types supported: F16/F32. - * @param[out] output Output tensor. Data types supported: same as @p input. - */ - void configure(const ITensor *input, ITensor *output); - /** Static function to check if given info will lead to a valid configuration of @ref NEExpLayer - * - * @param[in] input First tensor input info. Data types supported: F16/F32. - * @param[in] output Output tensor info. Data types supported: Same as @p input. - * - * @return a status - */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output); -}; - -/** Basic function to negate an input tensor. */ -class NENegLayer : public INESimpleFunctionNoBorder -{ -public: - /** Initialize the function - * - * @param[in] input Input tensor. Data types supported: F16/F32/S32. - * @param[out] output Output tensor. Data types supported: same as @p input. - */ - void configure(const ITensor *input, ITensor *output); - /** Static function to check if given info will lead to a valid configuration of @ref NENegLayer - * - * @param[in] input First tensor input info. Data types supported: F16/F32/S32. - * @param[in] output Output tensor info. Data types supported: Same as @p input. - * - * @return a status - */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output); -}; + /** Default Constructor */ + NEElementwiseUnaryLayer(); + /** Default Destructor */ + ~NEElementwiseUnaryLayer(); + /** Prevent instances of this class from being copied (As this class contains pointers) */ + NEElementwiseUnaryLayer(const NEElementwiseUnaryLayer &) = delete; + /** Default move constructor */ + NEElementwiseUnaryLayer(NEElementwiseUnaryLayer &&); + /** Prevent instances of this class from being copied (As this class contains pointers) */ + NEElementwiseUnaryLayer &operator=(const NEElementwiseUnaryLayer &) = delete; + /** Default move assignment operator */ + NEElementwiseUnaryLayer &operator=(NEElementwiseUnaryLayer &&); -/** Basic function to compute the natural logarithm of an input tensor. */ -class NELogLayer : public INESimpleFunctionNoBorder -{ -public: /** Initialize the function * - * @param[in] input Input tensor. Data types supported: F16/F32. - * @param[out] output Output tensor. Data types supported: same as @p input. + * @param[in] input Input tensor. Data types supported: F16/F32, F16/F32/S32 for NEG/ABS operations. + * @param[out] output Output tensor. Data types supported: Same as @p input. */ void configure(const ITensor *input, ITensor *output); - /** Static function to check if given info will lead to a valid configuration of @ref NELogLayer + /** Static function to check if given info will lead to a valid configuration * - * @param[in] input First tensor input info. Data types supported: F16/F32. + * @param[in] input Input tensor info. Data types supported: F16/F32, F16/F32/S32 for NEG/ABS operations. * @param[in] output Output tensor info. Data types supported: Same as @p input. * * @return a status */ static Status validate(const ITensorInfo *input, const ITensorInfo *output); -}; + // Inherited methods overridden: + void run() override; -/** Basic function to compute the absolute value of an input tensor. */ -class NEAbsLayer : public INESimpleFunctionNoBorder -{ -public: - /** Initialize the function - * - * @param[in] input Input tensor. Data types supported: F16/F32/S32. - * @param[out] output Output tensor. Data types supported: same as @p input. - */ - void configure(const ITensor *input, ITensor *output); - /** Static function to check if given info will lead to a valid configuration of @ref NEAbsLayer - * - * @param[in] input First tensor input info. Data types supported: F16/F32/S32. - * @param[in] output Output tensor info. Data types supported: Same as @p input. - * - * @return a status - */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output); +private: + struct Impl; + std::unique_ptr _impl; }; -/** Basic function to compute the round value elementwise of an input tensor. */ -class NERoundLayer : public INESimpleFunctionNoBorder -{ -public: - /** Initialize the function - * - * @param[in] input Input tensor. Data types supported: F16/F32. - * @param[out] output Output tensor. Data types supported: same as @p input. - */ - void configure(const ITensor *input, ITensor *output); - /** Static function to check if given info will lead to a valid configuration of @ref NERoundLayer - * - * @param[in] input First tensor input info. Data types supported: F16/F32. - * @param[in] output Output tensor info. Data types supported: Same as @p input. - * - * @return a status - */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output); -}; +using NERsqrtLayer = NEElementwiseUnaryLayer; +using NEExpLayer = NEElementwiseUnaryLayer; +using NENegLayer = NEElementwiseUnaryLayer; +using NELogLayer = NEElementwiseUnaryLayer; +using NEAbsLayer = NEElementwiseUnaryLayer; +using NERoundLayer = NEElementwiseUnaryLayer; +using NESinLayer = NEElementwiseUnaryLayer; -/** Basic function to compute the sine of an input tensor. */ -class NESinLayer : public INESimpleFunctionNoBorder -{ -public: - /** Initialize the function - * - * @param[in] input Input tensor. Data types supported: F16/F32. - * @param[out] output Output tensor. Data types supported: same as @p input. - */ - void configure(const ITensor *input, ITensor *output); - /** Static function to check if given info will lead to a valid configuration of @ref NESinLayer - * - * @param[in] input First tensor input info. Data types supported: F16/F32. - * @param[in] output Output tensor info. Data types supported: Same as @p input. - * - * @return a status - */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output); -}; } // namespace arm_compute #endif /* ARM_COMPUTE_NEELEMENTWISEUNARYLAYER_H */ -- cgit v1.2.1