From ab9e52563f624d9782b97400f643d2632cc8d770 Mon Sep 17 00:00:00 2001 From: Matteo Martincigh Date: Thu, 13 Jun 2019 17:27:46 +0100 Subject: IVGCVSW-3268 Add Reference workload support for the new Prelu Activation layer * Added reference workload for the PReLU Activation layer * Added factory methods * Added validation support * Added Int16 support * Added unit tests Change-Id: Ic950d908c5e0a335dccd2960a3ffab0f8b599876 Signed-off-by: Matteo Martincigh --- src/backends/reference/workloads/PreluImpl.cpp | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/backends/reference/workloads/PreluImpl.cpp (limited to 'src/backends/reference/workloads/PreluImpl.cpp') diff --git a/src/backends/reference/workloads/PreluImpl.cpp b/src/backends/reference/workloads/PreluImpl.cpp new file mode 100644 index 0000000000..458025bb0a --- /dev/null +++ b/src/backends/reference/workloads/PreluImpl.cpp @@ -0,0 +1,35 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "PreluImpl.hpp" +#include "RefWorkloadUtils.hpp" +#include "Broadcast.hpp" + +namespace armnn +{ + +void PreluImpl(const PreluQueueDescriptor& data, + Decoder& inputData, + Decoder& alphaData, + Encoder& outputData) +{ + const TensorInfo& inputInfo = GetTensorInfo(data.m_Inputs[0]); + const TensorInfo& alphaInfo = GetTensorInfo(data.m_Inputs[1]); + const TensorInfo& outputInfo = GetTensorInfo(data.m_Outputs[0]); + + const TensorShape& inputShape = inputInfo.GetShape(); + const TensorShape& alphaShape = alphaInfo.GetShape(); + const TensorShape& outputShape = outputInfo.GetShape(); + + // PReLU activation: f(x) = alpha * x for x < 0, f(x) = x for x >= 0 + auto prelu = [](float x, float alpha) + { + return x < 0 ? alpha * x : x; + }; + + BroadcastLoop(inputShape, alphaShape, outputShape).Unroll(prelu, 0, inputData, alphaData, outputData); +} + +} // namespace armnn -- cgit v1.2.1