blob: 50dafcac3cbc3b2186de337b92e353f9cf1d7019 [file] [log] [blame]
Aron Virginas-Tar735a4502019-06-26 15:02:47 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "RefTransposeConvolution2dWorkload.hpp"
7
8#include "RefWorkloadUtils.hpp"
9#include "TransposeConvolution2d.hpp"
10
11#include <Profiling.hpp>
12
13namespace armnn
14{
15
16RefTransposeConvolution2dWorkload::RefTransposeConvolution2dWorkload(
17 const TransposeConvolution2dQueueDescriptor& descriptor, const WorkloadInfo& info) :
18 BaseWorkload<TransposeConvolution2dQueueDescriptor>(descriptor, info)
19{
20 // set up weights decoder
21 m_Weights = std::make_unique<ScopedCpuTensorHandle>(*(descriptor.m_Weight));
22 const TensorInfo& weightsInfo = GetTensorInfo(m_Weights.get());
23
24 m_WeightsDecoder = MakeDecoder<float>(weightsInfo, m_Weights.get()->Map(true));
25 m_WeightsShape = weightsInfo.GetShape();
26
27 // set up biases decoder
28 if (descriptor.m_Parameters.m_BiasEnabled)
29 {
30 m_Biases = std::make_unique<ScopedCpuTensorHandle>(*(descriptor.m_Bias));
31 const TensorInfo& biasesInfo = GetTensorInfo(m_Biases.get());
32 m_BiasesDecoder = MakeDecoder<float>(biasesInfo, m_Biases.get()->Map(true));
33 }
34}
35
36void RefTransposeConvolution2dWorkload::PostAllocationConfigure()
37{
38 // set up input decoder
39 const ITensorHandle* input = m_Data.m_Inputs[0];
40 const TensorInfo& inputInfo = GetTensorInfo(input);
41
42 m_InputShape = inputInfo.GetShape();
43 m_InputDecoder = MakeDecoder<float>(inputInfo, input->Map());
44
45 // set up output encoder
46 ITensorHandle* output = m_Data.m_Outputs[0];
47 const TensorInfo& outputInfo = GetTensorInfo(output);
48
49 m_OutputShape = outputInfo.GetShape();
50 m_OutputEncoder = MakeEncoder<float>(outputInfo, output->Map());
51}
52
53void RefTransposeConvolution2dWorkload::Execute() const
54{
55 ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefTransposeConvolution2dWorkload_Execute");
56
57 TransposeConvolution2dImpl(m_Data.m_Parameters,
58 m_InputShape,
59 *m_InputDecoder,
60 m_OutputShape,
61 *m_OutputEncoder,
62 m_WeightsShape,
63 *m_WeightsDecoder,
64 m_BiasesDecoder.get());
65}
66
67} // namespace armnn