blob: 5a87520f84045d6aa04f10ec5f157918d04920db (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "FullyConnected.hpp"
#include "RefWorkloadUtils.hpp"
namespace armnn
{
void FullyConnected(const TensorShape& rInputShape,
Decoder<float>& rInputDecoder,
const TensorShape& rOutputShape,
Encoder<float>& rOutputEncoder,
Decoder<float>& rWeightDecoder,
Decoder<float>& rBiasDecoder,
const bool biasEnabled,
const unsigned int K,
const bool transposeWeights)
{
// Perform FullyConnected implementation
unsigned int outputSize = rOutputShape[1];
for (unsigned int n = 0; n < rInputShape[0]; n++)
{
for (unsigned int channelOutput = 0; channelOutput < outputSize; channelOutput++)
{
float outval = 0.f;
for (unsigned int channelInput = 0; channelInput < K; channelInput++)
{
float weight;
if (transposeWeights)
{
rWeightDecoder[channelOutput * K + channelInput];
weight = rWeightDecoder.Get();
}
else
{
rWeightDecoder[channelInput * outputSize + channelOutput];
weight = rWeightDecoder.Get();
}
rInputDecoder[n * K + channelInput];
outval += weight * rInputDecoder.Get();
}
if (biasEnabled)
{
rBiasDecoder[channelOutput];
outval += rBiasDecoder.Get();
}
rOutputEncoder[n * outputSize + channelOutput];
rOutputEncoder.Set(outval);
}
}
}
} //namespace armnn
|