aboutsummaryrefslogtreecommitdiff
path: root/src/backends/reference/workloads
diff options
context:
space:
mode:
authorTeresa Charlin <teresa.charlinreyes@arm.com>2021-05-31 18:47:33 +0100
committerJim Flynn <jim.flynn@arm.com>2021-06-16 14:26:12 +0000
commit50de4fa4e7e0dd02a442ba350a1b40f293cb5a01 (patch)
treeb37e0ae81033a1cb70911750affe2961682dd62d /src/backends/reference/workloads
parent2ef580100c8de1bf8acea854607ac1e552e9703f (diff)
downloadarmnn-50de4fa4e7e0dd02a442ba350a1b40f293cb5a01.tar.gz
IVGCVSW-6088 Add Sin and Log to ElementWiseUnary
* Ref workload * Cl workload * Neon workload * Serializer * Deserializer * Remove boost include from TensorTest.cpp Signed-off-by: Teresa Charlin <teresa.charlinreyes@arm.com> Change-Id: I498548169cc77609c55cf3105f1de5a7429772cf
Diffstat (limited to 'src/backends/reference/workloads')
-rw-r--r--src/backends/reference/workloads/CMakeLists.txt2
-rw-r--r--src/backends/reference/workloads/ElementwiseFunction.cpp6
-rw-r--r--src/backends/reference/workloads/Log.hpp23
-rw-r--r--src/backends/reference/workloads/RefElementwiseUnaryWorkload.cpp16
-rw-r--r--src/backends/reference/workloads/Sin.hpp22
5 files changed, 67 insertions, 2 deletions
diff --git a/src/backends/reference/workloads/CMakeLists.txt b/src/backends/reference/workloads/CMakeLists.txt
index dadedf995a..09e02e67bd 100644
--- a/src/backends/reference/workloads/CMakeLists.txt
+++ b/src/backends/reference/workloads/CMakeLists.txt
@@ -39,6 +39,7 @@ list(APPEND armnnRefBackendWorkloads_sources
Gather.hpp
InstanceNorm.cpp
InstanceNorm.hpp
+ Log.hpp
LogSoftmax.cpp
LogSoftmax.hpp
LstmUtils.hpp
@@ -165,6 +166,7 @@ list(APPEND armnnRefBackendWorkloads_sources
Resize.cpp
Resize.hpp
Rsqrt.hpp
+ Sin.hpp
Slice.cpp
Slice.hpp
Softmax.cpp
diff --git a/src/backends/reference/workloads/ElementwiseFunction.cpp b/src/backends/reference/workloads/ElementwiseFunction.cpp
index d6f3f42478..82bcf99287 100644
--- a/src/backends/reference/workloads/ElementwiseFunction.cpp
+++ b/src/backends/reference/workloads/ElementwiseFunction.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -10,7 +10,9 @@
#include "Maximum.hpp"
#include "Abs.hpp"
#include "Exp.hpp"
+#include "Log.hpp"
#include "Rsqrt.hpp"
+#include "Sin.hpp"
#include "Sqrt.hpp"
@@ -84,8 +86,10 @@ template struct armnn::ElementwiseBinaryFunction<std::not_equal_to<float>>;
// Unary
template struct armnn::ElementwiseUnaryFunction<armnn::abs<float>>;
template struct armnn::ElementwiseUnaryFunction<armnn::exp<float>>;
+template struct armnn::ElementwiseUnaryFunction<armnn::log<float>>;
template struct armnn::ElementwiseUnaryFunction<std::negate<float>>;
template struct armnn::ElementwiseUnaryFunction<armnn::rsqrt<float>>;
+template struct armnn::ElementwiseUnaryFunction<armnn::sin<float>>;
template struct armnn::ElementwiseUnaryFunction<armnn::sqrt<float>>;
// Logical Unary
diff --git a/src/backends/reference/workloads/Log.hpp b/src/backends/reference/workloads/Log.hpp
new file mode 100644
index 0000000000..98b6b824cc
--- /dev/null
+++ b/src/backends/reference/workloads/Log.hpp
@@ -0,0 +1,23 @@
+//
+// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <iostream>
+
+namespace armnn
+{
+ template<typename T>
+struct log : public std::unary_function<T, T>
+ {
+ T
+ operator () (const T& inputData) const
+ {
+ // computes natural logarithm of inputData
+ return std::log(inputData);
+ }
+ };
+
+} //namespace armnn
diff --git a/src/backends/reference/workloads/RefElementwiseUnaryWorkload.cpp b/src/backends/reference/workloads/RefElementwiseUnaryWorkload.cpp
index b442f25c2a..be153636f9 100644
--- a/src/backends/reference/workloads/RefElementwiseUnaryWorkload.cpp
+++ b/src/backends/reference/workloads/RefElementwiseUnaryWorkload.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -11,7 +11,9 @@
#include "RefWorkloadUtils.hpp"
#include "Abs.hpp"
#include "Exp.hpp"
+#include "Log.hpp"
#include "Rsqrt.hpp"
+#include "Sin.hpp"
#include "Sqrt.hpp"
#include <Profiling.hpp>
@@ -54,8 +56,10 @@ void RefElementwiseUnaryWorkload::Execute(std::vector<ITensorHandle*> inputs, st
using AbsFunction = ElementwiseUnaryFunction<abs<InType>>;
using ExpFunction = ElementwiseUnaryFunction<exp<InType>>;
+ using LogFunction = ElementwiseUnaryFunction<log<InType>>;
using NegFunction = ElementwiseUnaryFunction<std::negate<InType>>;
using RsqrtFunction = ElementwiseUnaryFunction<rsqrt<InType>>;
+ using SinFunction = ElementwiseUnaryFunction<sin<InType>>;
using SqrtFunction = ElementwiseUnaryFunction<sqrt<InType>>;
switch (m_Data.m_Parameters.m_Operation)
@@ -70,6 +74,11 @@ void RefElementwiseUnaryWorkload::Execute(std::vector<ITensorHandle*> inputs, st
ExpFunction(inShape, outShape, *input, *output);
break;
}
+ case UnaryOperation::Log:
+ {
+ LogFunction(inShape, outShape, *input, *output);
+ break;
+ }
case UnaryOperation::Neg:
{
NegFunction(inShape, outShape, *input, *output);
@@ -80,6 +89,11 @@ void RefElementwiseUnaryWorkload::Execute(std::vector<ITensorHandle*> inputs, st
RsqrtFunction(inShape, outShape, *input, *output);
break;
}
+ case UnaryOperation::Sin:
+ {
+ SinFunction(inShape, outShape, *input, *output);
+ break;
+ }
case UnaryOperation::Sqrt:
{
SqrtFunction(inShape, outShape, *input, *output);
diff --git a/src/backends/reference/workloads/Sin.hpp b/src/backends/reference/workloads/Sin.hpp
new file mode 100644
index 0000000000..b71c33bbf3
--- /dev/null
+++ b/src/backends/reference/workloads/Sin.hpp
@@ -0,0 +1,22 @@
+//
+// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <iostream>
+
+namespace armnn
+{
+ template<typename T>
+struct sin : public std::unary_function<T, T>
+ {
+ T
+ operator () (const T& inputData) const
+ {
+ return std::sin(inputData);
+ }
+ };
+
+} //namespace armnn