aboutsummaryrefslogtreecommitdiff
path: root/src/backends/reference/workloads/RefTransposeConvolution2dWorkload.cpp
blob: 50dafcac3cbc3b2186de337b92e353f9cf1d7019 (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
63
64
65
66
67
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//

#include "RefTransposeConvolution2dWorkload.hpp"

#include "RefWorkloadUtils.hpp"
#include "TransposeConvolution2d.hpp"

#include <Profiling.hpp>

namespace armnn
{

RefTransposeConvolution2dWorkload::RefTransposeConvolution2dWorkload(
    const TransposeConvolution2dQueueDescriptor& descriptor, const WorkloadInfo& info) :
    BaseWorkload<TransposeConvolution2dQueueDescriptor>(descriptor, info)
{
    // set up weights decoder
    m_Weights = std::make_unique<ScopedCpuTensorHandle>(*(descriptor.m_Weight));
    const TensorInfo& weightsInfo = GetTensorInfo(m_Weights.get());

    m_WeightsDecoder = MakeDecoder<float>(weightsInfo, m_Weights.get()->Map(true));
    m_WeightsShape   = weightsInfo.GetShape();

    // set up biases decoder
    if (descriptor.m_Parameters.m_BiasEnabled)
    {
        m_Biases = std::make_unique<ScopedCpuTensorHandle>(*(descriptor.m_Bias));
        const TensorInfo& biasesInfo = GetTensorInfo(m_Biases.get());
        m_BiasesDecoder = MakeDecoder<float>(biasesInfo, m_Biases.get()->Map(true));
    }
}

void RefTransposeConvolution2dWorkload::PostAllocationConfigure()
{
    // set up input decoder
    const ITensorHandle* input  = m_Data.m_Inputs[0];
    const TensorInfo& inputInfo = GetTensorInfo(input);

    m_InputShape   = inputInfo.GetShape();
    m_InputDecoder = MakeDecoder<float>(inputInfo, input->Map());

    // set up output encoder
    ITensorHandle* output        = m_Data.m_Outputs[0];
    const TensorInfo& outputInfo = GetTensorInfo(output);

    m_OutputShape   = outputInfo.GetShape();
    m_OutputEncoder = MakeEncoder<float>(outputInfo, output->Map());
}

void RefTransposeConvolution2dWorkload::Execute() const
{
    ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefTransposeConvolution2dWorkload_Execute");

    TransposeConvolution2dImpl(m_Data.m_Parameters,
                               m_InputShape,
                               *m_InputDecoder,
                               m_OutputShape,
                               *m_OutputEncoder,
                               m_WeightsShape,
                               *m_WeightsDecoder,
                               m_BiasesDecoder.get());
}

} // namespace armnn