diff options
author | Sang-Hoon Park <sang-hoon.park@arm.com> | 2021-02-17 13:12:53 +0000 |
---|---|---|
committer | Georgios Pinitas <georgios.pinitas@arm.com> | 2021-03-11 14:50:55 +0000 |
commit | 6b0bf9972975aff01e42e5790f7b7c98cd835afb (patch) | |
tree | 5e0a50af1e5a7e325621d762d7a6c523592d2e6f /src/runtime/cpu/operators/CpuElementwise.h | |
parent | d7de9c50c85be2a01b9fef2867c3be140685fd6d (diff) | |
download | ComputeLibrary-6b0bf9972975aff01e42e5790f7b7c98cd835afb.tar.gz |
Add CpuPRelu operators
Implements: COMPMID-4184
Change-Id: I252168b460a18f837a26df5641664e95ddbd9c7e
Signed-off-by: Sang-Hoon Park <sang-hoon.park@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5237
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Manuel Bottini <manuel.bottini@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/runtime/cpu/operators/CpuElementwise.h')
-rw-r--r-- | src/runtime/cpu/operators/CpuElementwise.h | 84 |
1 files changed, 20 insertions, 64 deletions
diff --git a/src/runtime/cpu/operators/CpuElementwise.h b/src/runtime/cpu/operators/CpuElementwise.h index 4b350d5f9f..899a2ffdb7 100644 --- a/src/runtime/cpu/operators/CpuElementwise.h +++ b/src/runtime/cpu/operators/CpuElementwise.h @@ -36,83 +36,39 @@ public: // Inherited methods overridden: void run(ITensorPack &tensors) override; }; -/** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for max +/** Class to run @ref cpu::kernels::CpuArithmeticKernel except for division and power * - * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. - * @note The function performs a max operation between two tensors. - */ -class CpuElementwiseMax : public CpuElementwiseBase -{ -public: - /** Initialise the kernel's inputs, dst and conversion policy. - * - * @param[in, out] src0 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. - * @param[in, out] src1 Second tensor input info. Data types supported: Same as @p src0. - * @param[out] dst Output tensor info. Data types supported: Same as @p src0. - */ - void configure(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst); - /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuArithmeticKernel for max - * - * @param[in] src0 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. - * @param[in] src1 Second tensor input info. Data types supported: Same as @p src0. - * @param[in] dst Output tensor info. Data types supported: Same as @p src0. - * - * @return a status - */ - static Status validate(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst); -}; - -/** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for min - * - * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. - * @note The function performs a min operation between two tensors. + * @note Max/Min/Squared difference supports input data type of QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32 + * @note PRelu supports inpute data type of QASYMM8/QASYMM8_SIGNED/F16/F32. */ -class CpuElementwiseMin : public CpuElementwiseBase +template <ArithmeticOperation op> +class CpuElementwiseArithmetic : public CpuElementwiseBase { public: - /** Initialise the kernel's inputs, dst and conversion policy. + /** Configure the operator * - * @param[in, out] src0 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. - * @param[in, out] src1 Second tensor input info. Data types supported: Same as @p src0. - * @param[out] dst Output tensor info. Data types supported: Same as @p src0. + * @param[in] src0 The first source tensor information. + * @param[in] src1 The second source tensor information. With PRelu, this is used as alpha tensor. + * @param[out] dst The output tensor information. */ void configure(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst); - /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuArithmeticKernel for min + /** Static function to check if the given information will lead to a valid configuration * - * @param[in] src0 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. - * @param[in] src1 Second tensor input info. Data types supported: Same as @p src0. - * @param[in] dst Output tensor info. Data types supported: Same as @p src0. + * @param[in] src0 The first source tensor information. + * @param[in] src1 The second source tensor information. With PRelu, this is used as alpha tensor. + * @param[out] dst The output tensor information. * - * @return a status + * @return A status */ static Status validate(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst); }; -/** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for squared difference - * - * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. - * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2 - */ -class CpuElementwiseSquaredDiff : public CpuElementwiseBase -{ -public: - /** Initialise the kernel's inputs, dst and conversion policy. - * - * @param[in, out] src0 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. - * @param[in, out] src1 Second tensor input info. Data types supported: Same as @p src0. - * @param[out] dst Output tensor info. Data types supported: Same as @p src0. - */ - void configure(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst); - /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuArithmeticKernel for squared difference - * - * @param[in] src0 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. - * @param[in] src1 Second tensor input info. Data types supported: Same as @p src0. - * @param[in] dst Output tensor info. Data types supported: Same as @p src0. - * - * @return a status - */ - static Status validate(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst); -}; +/** Class to run @ref cpu::kernels::CpuArithmeticKernel except for maximum operation */ +using CpuElementwiseMax = CpuElementwiseArithmetic<ArithmeticOperation::MAX>; +/** Class to run @ref cpu::kernels::CpuArithmeticKernel except for minimum operation */ +using CpuElementwiseMin = CpuElementwiseArithmetic<ArithmeticOperation::MIN>; +/** Class to run @ref cpu::kernels::CpuArithmeticKernel except for squared difference operation */ +using CpuElementwiseSquaredDiff = CpuElementwiseArithmetic<ArithmeticOperation::SQUARED_DIFF>; /** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for division * |