blob: af2c7ad0d668a70d059fcf8d615797b2c0ab7248 [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 "RefConvolution2dUint8Workload.hpp"
7
8#include "ConvImpl.hpp"
9#include "RefWorkloadUtils.hpp"
10
11#include "Profiling.hpp"
12
13namespace armnn
14{
telsoa01c577f2c2018-08-31 09:22:23 +010015RefConvolution2dUint8Workload::RefConvolution2dUint8Workload(
16 const Convolution2dQueueDescriptor& descriptor, const WorkloadInfo& info)
17 : Uint8Workload<Convolution2dQueueDescriptor>(descriptor, info),
18 m_Weight(std::make_unique<ScopedCpuTensorHandle>(*(descriptor.m_Weight))),
19 m_Bias(descriptor.m_Parameters.m_BiasEnabled
20 ? std::make_unique<ScopedCpuTensorHandle>(*(descriptor.m_Bias)) : nullptr) {}
telsoa014fcda012018-03-09 14:13:49 +000021
22void RefConvolution2dUint8Workload::Execute() const
23{
24 ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefConvolution2dUint8Workload_Execute");
25
26 const uint8_t* inputData = GetInputTensorDataU8(0, m_Data);
27 const TensorInfo& inputInfo = GetTensorInfo(m_Data.m_Inputs[0]);
telsoa01c577f2c2018-08-31 09:22:23 +010028 const uint8_t* weightsData = m_Weight->template GetConstTensor<uint8_t>();
29 const TensorInfo& weightsInfo = GetTensorInfo(m_Weight.get());
Matteo Martincigh747ef822018-12-18 09:26:39 +000030 const int32_t* biasData = m_Data.m_Parameters.m_BiasEnabled ? m_Bias->template GetConstTensor<int32_t>() : nullptr;
telsoa014fcda012018-03-09 14:13:49 +000031 const TensorInfo& outputInfo = GetTensorInfo(m_Data.m_Outputs[0]);
telsoa01c577f2c2018-08-31 09:22:23 +010032 const TensorInfo& filterInfo = m_Weight->GetTensorInfo();
telsoa014fcda012018-03-09 14:13:49 +000033
34 ConvImpl<armnn::Convolution2dQueueDescriptor, uint8_t, int32_t, int32_t>(
35 m_Data,
36 inputData, inputInfo.GetQuantizationScale(), inputInfo.GetQuantizationOffset(),
37 weightsData, weightsInfo.GetQuantizationScale(), weightsInfo.GetQuantizationOffset(),
38 biasData,
Matteo Martincigh747ef822018-12-18 09:26:39 +000039 outputInfo.GetQuantizationScale(), outputInfo.GetQuantizationOffset(), filterInfo);
telsoa014fcda012018-03-09 14:13:49 +000040}
41
42} //namespace armnn