blob: 3ddbdcebcae255d39d16372d3c9ad9e762a6f2da [file] [log] [blame]
Mike Kelly9b398322019-05-22 17:21:49 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "RefConvolution2dWorkload.hpp"
7
8#include "ConvImpl.hpp"
9#include "RefWorkloadUtils.hpp"
10
11#include "Profiling.hpp"
12
13namespace armnn
14{
Keith Davisb4dd5cc2022-04-07 11:32:00 +010015RefConvolution2dWorkload::RefConvolution2dWorkload(const Convolution2dQueueDescriptor& descriptor,
16 const WorkloadInfo& info)
Finn Williams73c547d2022-02-15 20:47:34 +000017 : RefBaseWorkload<Convolution2dQueueDescriptor>(descriptor, info)
Finn Williamsd0420cb2022-05-18 13:24:14 +010018 , m_InputShape(info.m_InputTensorInfos[0].GetShape())
19 , m_FilterShape(info.m_InputTensorInfos[1].GetShape())
20 , m_OutputShape(info.m_OutputTensorInfos[0].GetShape())
Mike Kelly9b398322019-05-22 17:21:49 +010021{
Keith Davis554fa092021-07-20 11:25:22 +010022 WorkloadInfo detailsInfo;
23 detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
24 detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
Keith Davis554fa092021-07-20 11:25:22 +010025
26 // Report Profiling Details
Keith Davisf4874862021-08-09 16:49:18 +010027 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("RefConvolution2dWorkload_Construct",
Keith Davis5a64f222021-08-04 10:35:20 +010028 descriptor.m_Parameters,
29 detailsInfo,
30 this->GetGuid());
Keith Davisb4dd5cc2022-04-07 11:32:00 +010031}
Keith Davis554fa092021-07-20 11:25:22 +010032
Finn Williamsb8181f72021-04-07 10:23:21 +010033void RefConvolution2dWorkload::Execute() const
Mike Kelly9b398322019-05-22 17:21:49 +010034{
Finn Williamsb8181f72021-04-07 10:23:21 +010035 Execute(m_Data.m_Inputs, m_Data.m_Outputs);
Mike Kelly9b398322019-05-22 17:21:49 +010036}
37
Keith Davis554fa092021-07-20 11:25:22 +010038void RefConvolution2dWorkload::ExecuteAsync(WorkingMemDescriptor& workingMemDescriptor)
Finn Williamsb8181f72021-04-07 10:23:21 +010039{
40 Execute(workingMemDescriptor.m_Inputs, workingMemDescriptor.m_Outputs);
41}
42
Keith Davis554fa092021-07-20 11:25:22 +010043void RefConvolution2dWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const
44{
Keith Davis5a64f222021-08-04 10:35:20 +010045 ARMNN_SCOPED_PROFILING_EVENT_GUID(Compute::CpuRef, "RefConvolution2dWorkload_Execute", this->GetGuid());
Mike Kelly9b398322019-05-22 17:21:49 +010046
Finn Williamsb8181f72021-04-07 10:23:21 +010047 std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(GetTensorInfo(inputs[0]), inputs[0]->Map());
48 std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]), outputs[0]->Map());
Matthew Benthamc394a6d2019-06-24 12:51:25 +010049
Finn Williamsd0420cb2022-05-18 13:24:14 +010050 std::unique_ptr<Decoder<float>> weightsDecoder = MakeDecoder<float>(GetTensorInfo(inputs[1]), inputs[1]->Map());
51 std::unique_ptr<Decoder<float>> biasDecoder;
52
Keith Davisb4dd5cc2022-04-07 11:32:00 +010053 if (m_Data.m_Parameters.m_BiasEnabled)
54 {
Finn Williamsd0420cb2022-05-18 13:24:14 +010055 biasDecoder = MakeDecoder<float>(GetTensorInfo(inputs[2]), inputs[2]->Map());
Keith Davisb4dd5cc2022-04-07 11:32:00 +010056 }
Finn Williamsb8181f72021-04-07 10:23:21 +010057
Keith Davisb4dd5cc2022-04-07 11:32:00 +010058 Convolve(m_InputShape, *inputDecoder, m_OutputShape, *outputEncoder, m_FilterShape,
Finn Williamsd0420cb2022-05-18 13:24:14 +010059 *weightsDecoder, m_Data.m_Parameters.m_BiasEnabled, biasDecoder.get(),
Mike Kelly9b398322019-05-22 17:21:49 +010060 m_Data.m_Parameters.m_DataLayout, m_Data.m_Parameters.m_PadTop, m_Data.m_Parameters.m_PadLeft,
61 m_Data.m_Parameters.m_StrideX, m_Data.m_Parameters.m_StrideY,
62 m_Data.m_Parameters.m_DilationX, m_Data.m_Parameters.m_DilationY);
63}
64
Keith Davisb4dd5cc2022-04-07 11:32:00 +010065} //namespace armnn