blob: 458025bb0a917757e2bb8bacea3f58146e027c9c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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<float>& inputData,
Decoder<float>& alphaData,
Encoder<float>& 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
|