aboutsummaryrefslogtreecommitdiff
path: root/src/backends/reference/workloads/RefDepthwiseConvolution2dUint8Workload.cpp
blob: 629b729ea6d8b81865853f62dec086782981d78b (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
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//

#include "RefDepthwiseConvolution2dUint8Workload.hpp"

#include "ConvImpl.hpp"
#include "RefWorkloadUtils.hpp"

#include "Profiling.hpp"

namespace armnn
{

RefDepthwiseConvolution2dUint8Workload::RefDepthwiseConvolution2dUint8Workload(
        const DepthwiseConvolution2dQueueDescriptor& descriptor, const WorkloadInfo& info)
        : Uint8Workload<DepthwiseConvolution2dQueueDescriptor>(descriptor, info),
          m_Weight(std::make_unique<ScopedCpuTensorHandle>(*(descriptor.m_Weight))),
          m_Bias(descriptor.m_Parameters.m_BiasEnabled
                 ? std::make_unique<ScopedCpuTensorHandle>(*(descriptor.m_Bias)) : nullptr) {}

void RefDepthwiseConvolution2dUint8Workload::Execute() const
{
    ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefDepthwiseConvolution2dUint8Workload_Execute");

    const uint8_t* inputData = GetInputTensorDataU8(0, m_Data);
    const TensorInfo& inputInfo = GetTensorInfo(m_Data.m_Inputs[0]);
    const uint8_t* weightsData = m_Weight->template GetConstTensor<uint8_t>();
    const TensorInfo& weightsInfo = GetTensorInfo(m_Weight.get());
    const int32_t* biasData = m_Data.m_Parameters.m_BiasEnabled ? m_Bias->template GetConstTensor<int32_t>() : nullptr;
    const TensorInfo& outputInfo = GetTensorInfo(m_Data.m_Outputs[0]);
    const TensorInfo& filterInfo = m_Weight->GetTensorInfo();

    ConvImpl<armnn::DepthwiseConvolution2dQueueDescriptor, uint8_t, int32_t, int32_t>(
        m_Data,
        inputData, inputInfo.GetQuantizationScale(),  inputInfo.GetQuantizationOffset(),
        weightsData, weightsInfo.GetQuantizationScale(), weightsInfo.GetQuantizationOffset(),
        biasData,
        outputInfo.GetQuantizationScale(), outputInfo.GetQuantizationOffset(), filterInfo, true);
}

} //namespace armnn