blob: e8e501d6aeb0b5de28668d77085add15778f867f [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5
6#include "RefDepthwiseConvolution2dUint8Workload.hpp"
7
8#include "ConvImpl.hpp"
9#include "RefWorkloadUtils.hpp"
10
11#include "Profiling.hpp"
12
13namespace armnn
14{
15
telsoa01c577f2c2018-08-31 09:22:23 +010016RefDepthwiseConvolution2dUint8Workload::RefDepthwiseConvolution2dUint8Workload(
17 const DepthwiseConvolution2dQueueDescriptor& descriptor, const WorkloadInfo& info)
18 : Uint8Workload<DepthwiseConvolution2dQueueDescriptor>(descriptor, info),
19 m_Weight(std::make_unique<ScopedCpuTensorHandle>(*(descriptor.m_Weight))),
20 m_Bias(descriptor.m_Parameters.m_BiasEnabled
21 ? std::make_unique<ScopedCpuTensorHandle>(*(descriptor.m_Bias)) : nullptr) {}
22
telsoa014fcda012018-03-09 14:13:49 +000023void RefDepthwiseConvolution2dUint8Workload::Execute() const
24{
25 ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefDepthwiseConvolution2dUint8Workload_Execute");
26
27 const uint8_t* inputData = GetInputTensorDataU8(0, m_Data);
28 const TensorInfo& inputInfo = GetTensorInfo(m_Data.m_Inputs[0]);
telsoa01c577f2c2018-08-31 09:22:23 +010029 const uint8_t* weightsData = m_Weight->template GetConstTensor<uint8_t>();
30 const TensorInfo& weightsInfo = GetTensorInfo(m_Weight.get());
telsoa014fcda012018-03-09 14:13:49 +000031 const int32_t* biasData = m_Data.m_Parameters.m_BiasEnabled ?
telsoa01c577f2c2018-08-31 09:22:23 +010032 m_Bias->template GetConstTensor<int32_t>() :
telsoa014fcda012018-03-09 14:13:49 +000033 nullptr;
34 uint8_t* outputData = GetOutputTensorDataU8(0, m_Data);
35 const TensorInfo& outputInfo = GetTensorInfo(m_Data.m_Outputs[0]);
telsoa01c577f2c2018-08-31 09:22:23 +010036 const TensorInfo& filterInfo = m_Weight->GetTensorInfo();
telsoa014fcda012018-03-09 14:13:49 +000037
38 ConvImpl<armnn::DepthwiseConvolution2dQueueDescriptor, uint8_t, int32_t, int32_t>(
39 m_Data,
40 inputData, inputInfo.GetQuantizationScale(), inputInfo.GetQuantizationOffset(),
41 weightsData, weightsInfo.GetQuantizationScale(), weightsInfo.GetQuantizationOffset(),
42 biasData,
telsoa01c577f2c2018-08-31 09:22:23 +010043 outputData, outputInfo.GetQuantizationScale(), outputInfo.GetQuantizationOffset(), filterInfo, true);
telsoa014fcda012018-03-09 14:13:49 +000044}
45
46} //namespace armnn