From a1e7e2818ab282e4d3b707feb5783b4bd4fbe45b Mon Sep 17 00:00:00 2001 From: George Wort Date: Tue, 15 Jan 2019 11:00:29 +0000 Subject: COMPMID-1768: NEON: Implement RealDiv Change-Id: I0868669f7b733df141794fba1d79436e7581bd3a Reviewed-on: https://review.mlplatform.org/426 Reviewed-by: Georgios Pinitas Tested-by: Arm Jenkins --- .../NEON/kernels/NEElementwiseOperationKernel.cpp | 42 +++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'src/core/NEON/kernels/NEElementwiseOperationKernel.cpp') diff --git a/src/core/NEON/kernels/NEElementwiseOperationKernel.cpp b/src/core/NEON/kernels/NEElementwiseOperationKernel.cpp index 88fd730554..99a3b5ac66 100644 --- a/src/core/NEON/kernels/NEElementwiseOperationKernel.cpp +++ b/src/core/NEON/kernels/NEElementwiseOperationKernel.cpp @@ -123,6 +123,11 @@ inline ScalarType elementwise_arithm_op_scalar(const ScalarType &a, const Scalar res = (a - b) * (a - b); break; } + case ArithmeticOperation::DIV: + { + res = a / b; + break; + } default: ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); } @@ -154,7 +159,6 @@ inline VectorType elementwise_arithm_op(const VectorType &a, const VectorType &b res = wrapper::vmul(tmp, tmp); break; } - default: ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); } @@ -162,6 +166,20 @@ inline VectorType elementwise_arithm_op(const VectorType &a, const VectorType &b return res; } +template <> +inline float32x4_t elementwise_arithm_op(const float32x4_t &a, const float32x4_t &b) +{ + return wrapper::vdiv(a, b); +} + +#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC +template <> +inline float16x8_t elementwise_arithm_op(const float16x8_t &a, const float16x8_t &b) +{ + return wrapper::vdiv(a, b); +} +#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC + template inline float32x4x4_t elementwise_arithm_op(const float32x4x4_t &a, const float32x4x4_t &b) { @@ -833,6 +851,28 @@ Status NEArithmeticOperationKernel::validate(ArithmeticOperation op, const ITens return Status{}; } +/** The division operator */ + +void NEDivisionOperationKernel::configure(const ITensor *input1, const ITensor *input2, ITensor *output) +{ + ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(*input1->info(), *input2->info(), *output->info())); + configure_common(input1, input2, output); + _function = configure_arithm_func(input1, input2, output); +} + +Status NEDivisionOperationKernel::validate_arguments(const ITensorInfo &input1, const ITensorInfo &input2, const ITensorInfo &output) +{ + ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&input1, 1, DataType::F16, DataType::F32); + return NEArithmeticOperationKernel::validate_arguments(input1, input2, output); +} + +Status NEDivisionOperationKernel::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output) +{ + ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input1, input2, output); + ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(*input1, *input2, *output)); + return Status{}; +} + /** Comparison operators (equal, not equal, less than, greater than, less than or equal, greater than or equal) */ void NEComparisonOperationKernel::configure(ComparisonOperation op, const ITensor *input1, const ITensor *input2, ITensor *output) -- cgit v1.2.1