aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManuel Bottini <manuel.bottini@arm.com>2019-05-15 15:30:47 +0100
committerManuel Bottini <manuel.bottini@arm.com>2019-07-17 10:19:00 +0000
commited753266948314922ee56b0d4a3e801264011a12 (patch)
tree24c509710ed2a7082f6ccecdc7ed20c6ae314595 /src
parent2ea3761416aab259d9d84620dba2e011bcb5d880 (diff)
downloadComputeLibrary-ed753266948314922ee56b0d4a3e801264011a12.tar.gz
COMPMID-2283: Implement SIN operator for NEON
Change-Id: I31ee0e7c9a30540cfd2cad76993afb66abfccc4d Signed-off-by: Manuel Bottini <manuel.bottini@arm.com> Reviewed-on: https://review.mlplatform.org/c/1169 Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/NEON/kernels/NEElementwiseUnaryKernel.cpp14
-rw-r--r--src/runtime/NEON/functions/NEElementwiseUnaryLayer.cpp11
2 files changed, 22 insertions, 3 deletions
diff --git a/src/core/NEON/kernels/NEElementwiseUnaryKernel.cpp b/src/core/NEON/kernels/NEElementwiseUnaryKernel.cpp
index 45f0fedebb..5d3af3b03d 100644
--- a/src/core/NEON/kernels/NEElementwiseUnaryKernel.cpp
+++ b/src/core/NEON/kernels/NEElementwiseUnaryKernel.cpp
@@ -65,13 +65,15 @@ inline ScalarType elementwise_op_scalar(const ScalarType &a)
return std::abs(a);
case ElementWiseUnary::ROUND:
return support::cpp11::nearbyint(a);
+ case ElementWiseUnary::SIN:
+ return std::sin(a);
default:
ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
}
}
/* Elementwise operations that are supported for float */
-template <ElementWiseUnary op, bool is_float, typename VectorType, typename std::enable_if<is_float, int>::type = 0>
+template <ElementWiseUnary op, typename ScalarType, bool is_float, typename VectorType, typename std::enable_if<is_float, int>::type = 0>
inline VectorType elementwise_op(const VectorType &a)
{
switch(op)
@@ -88,13 +90,15 @@ inline VectorType elementwise_op(const VectorType &a)
return wrapper::vabs(a);
case ElementWiseUnary::ROUND:
return wrapper::vround(a);
+ case ElementWiseUnary::SIN:
+ return wrapper::vsin(a);
default:
ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
}
}
/* Elementwise operations that are supported for non floats */
-template < ElementWiseUnary op, bool is_float, typename VectorType, typename std::enable_if < !is_float, int >::type = 0 >
+template < ElementWiseUnary op, typename ScalarType, bool is_float, typename VectorType, typename std::enable_if < !is_float, int >::type = 0 >
inline VectorType elementwise_op(const VectorType &a)
{
switch(op)
@@ -129,7 +133,7 @@ void elementwise_op(const ITensor *in, ITensor *out, const Window &window)
int x = window_start_x;
for(; x <= window_end_x - window_step_x; x += window_step_x)
{
- wrapper::vstore(output_ptr + x, elementwise_op<op, is_float>(wrapper::vloadq(input_ptr + x)));
+ wrapper::vstore(output_ptr + x, elementwise_op<op, ScalarType, is_float>(wrapper::vloadq(input_ptr + x)));
}
for(; x < window_end_x; ++x)
{
@@ -215,6 +219,9 @@ void NEElementwiseUnaryKernel::configure(ElementWiseUnary op, const ITensor *inp
case ElementWiseUnary::ROUND:
_function = configure_func<ElementWiseUnary::ROUND>(input, output);
break;
+ case ElementWiseUnary::SIN:
+ _function = configure_func<ElementWiseUnary::SIN>(input, output);
+ break;
default:
ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
}
@@ -229,6 +236,7 @@ Status NEElementwiseUnaryKernel::validate_arguments(ElementWiseUnary op, const I
case ElementWiseUnary::RSQRT:
case ElementWiseUnary::LOG:
case ElementWiseUnary::ROUND:
+ case ElementWiseUnary::SIN:
ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&input, 1, DataType::F16, DataType::F32);
break;
case ElementWiseUnary::NEG:
diff --git a/src/runtime/NEON/functions/NEElementwiseUnaryLayer.cpp b/src/runtime/NEON/functions/NEElementwiseUnaryLayer.cpp
index e4c9101274..4b44a05a64 100644
--- a/src/runtime/NEON/functions/NEElementwiseUnaryLayer.cpp
+++ b/src/runtime/NEON/functions/NEElementwiseUnaryLayer.cpp
@@ -96,4 +96,15 @@ Status NERoundLayer::validate(const ITensorInfo *input, const ITensorInfo *outpu
return NEElementwiseUnaryKernel::validate(ElementWiseUnary::ROUND, input, output);
}
+void NESinLayer::configure(const ITensor *input, ITensor *output)
+{
+ auto k = arm_compute::support::cpp14::make_unique<NEElementwiseUnaryKernel>();
+ k->configure(ElementWiseUnary::SIN, input, output);
+ _kernel = std::move(k);
+}
+Status NESinLayer::validate(const ITensorInfo *input, const ITensorInfo *output)
+{
+ return NEElementwiseUnaryKernel::validate(ElementWiseUnary::SIN, input, output);
+}
+
} // namespace arm_compute