ArmNN
 25.11
Loading...
Searching...
No Matches
RefFullyConnectedWorkload.cpp
Go to the documentation of this file.
1//
2// Copyright © 2019-2024 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
7
8#include "FullyConnected.hpp"
10
11#include "Profiling.hpp"
12
13namespace armnn
14{
15
16unsigned int GetNumActivations(const TensorInfo& inputInfo)
17{
18 unsigned int numActivations = 1; // Total number of activations in the input.
19 for (unsigned int i = 1; i < inputInfo.GetNumDimensions(); i++)
20 {
21 numActivations *= inputInfo.GetShape()[i];
22 }
23 return numActivations;
24}
25
26
28 const FullyConnectedQueueDescriptor& descriptor, const WorkloadInfo& info)
30 , m_InputShape(info.m_InputTensorInfos[0].GetShape())
31 , m_WeightShape(info.m_InputTensorInfos[1].GetShape())
32 , m_OutputShape(info.m_OutputTensorInfos[0].GetShape())
33 , m_NumActivations(GetNumActivations(info.m_InputTensorInfos[0]))
34{
35}
36
38{
39 Execute(m_Data.m_Inputs, m_Data.m_Outputs);
40}
41
42void RefFullyConnectedWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const
43{
44 ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID("RefFullyConnectedWorkload_Execute");
45
46 std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(GetTensorInfo(inputs[0]), inputs[0]->Map());
47 std::unique_ptr<Encoder<float>> OutputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]), outputs[0]->Map());
48
49 std::unique_ptr<Decoder<float>> weightsDecoder = MakeDecoder<float>(GetTensorInfo(inputs[1]), inputs[1]->Map());
50 std::unique_ptr<Decoder<float>> biasDecoder;
51
53 {
54 biasDecoder = MakeDecoder<float>(GetTensorInfo(inputs[2]), inputs[2]->Map());
55 }
56
57 FullyConnected(m_InputShape,
58 *inputDecoder,
59 m_OutputShape,
60 *OutputEncoder,
61 m_WeightShape,
62 *weightsDecoder,
63 biasDecoder.get(),
65 m_NumActivations,
67}
68
69} //namespace armnn
#define ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
RefBaseWorkload(const FullyConnectedQueueDescriptor &descriptor, const WorkloadInfo &info)
RefFullyConnectedWorkload(const FullyConnectedQueueDescriptor &descriptor, const WorkloadInfo &info)
const TensorShape & GetShape() const
Definition Tensor.hpp:193
unsigned int GetNumDimensions() const
Definition Tensor.hpp:197
Copyright (c) 2021 ARM Limited and Contributors.
unsigned int GetNumActivations(const TensorInfo &inputInfo)
std::unique_ptr< Decoder< T > > MakeDecoder(const TensorInfo &info, const void *data=nullptr)
std::unique_ptr< Encoder< T > > MakeEncoder(const TensorInfo &info, void *data=nullptr)
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
bool m_TransposeWeightMatrix
Enable/disable transpose weight matrix.
bool m_BiasEnabled
Enable/disable bias.
Contains information about TensorInfos of a layer.