blob: 1adeb6dd9339b8e9e4dbef0647ffcd54bf992550 [file] [log] [blame]
Mike Kelly9b398322019-05-22 17:21:49 +01001//
Mike Kelly7cbe7812023-07-25 17:37:33 +01002// Copyright © 2017,2019,2021-2023 Arm Ltd and Contributors. All rights reserved.
Mike Kelly9b398322019-05-22 17:21:49 +01003// 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
Matthew Sloyan2d213a72022-06-30 17:13:04 +010038void RefConvolution2dWorkload::ExecuteAsync(ExecutionData& executionData)
Finn Williamsb8181f72021-04-07 10:23:21 +010039{
Matthew Sloyan2d213a72022-06-30 17:13:04 +010040 WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data);
41 Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs);
Finn Williamsb8181f72021-04-07 10:23:21 +010042}
43
Keith Davis554fa092021-07-20 11:25:22 +010044void RefConvolution2dWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const
45{
Mike Kelly7cbe7812023-07-25 17:37:33 +010046 ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID("RefConvolution2dWorkload_Execute");
Mike Kelly9b398322019-05-22 17:21:49 +010047
Finn Williamsb8181f72021-04-07 10:23:21 +010048 std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(GetTensorInfo(inputs[0]), inputs[0]->Map());
49 std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]), outputs[0]->Map());
Matthew Benthamc394a6d2019-06-24 12:51:25 +010050
Finn Williamsd0420cb2022-05-18 13:24:14 +010051 std::unique_ptr<Decoder<float>> weightsDecoder = MakeDecoder<float>(GetTensorInfo(inputs[1]), inputs[1]->Map());
52 std::unique_ptr<Decoder<float>> biasDecoder;
53
Keith Davisb4dd5cc2022-04-07 11:32:00 +010054 if (m_Data.m_Parameters.m_BiasEnabled)
55 {
Finn Williamsd0420cb2022-05-18 13:24:14 +010056 biasDecoder = MakeDecoder<float>(GetTensorInfo(inputs[2]), inputs[2]->Map());
Keith Davisb4dd5cc2022-04-07 11:32:00 +010057 }
Finn Williamsb8181f72021-04-07 10:23:21 +010058
Keith Davisb4dd5cc2022-04-07 11:32:00 +010059 Convolve(m_InputShape, *inputDecoder, m_OutputShape, *outputEncoder, m_FilterShape,
Finn Williamsd0420cb2022-05-18 13:24:14 +010060 *weightsDecoder, m_Data.m_Parameters.m_BiasEnabled, biasDecoder.get(),
Mike Kelly9b398322019-05-22 17:21:49 +010061 m_Data.m_Parameters.m_DataLayout, m_Data.m_Parameters.m_PadTop, m_Data.m_Parameters.m_PadLeft,
62 m_Data.m_Parameters.m_StrideX, m_Data.m_Parameters.m_StrideY,
63 m_Data.m_Parameters.m_DilationX, m_Data.m_Parameters.m_DilationY);
64}
65
Keith Davisb4dd5cc2022-04-07 11:32:00 +010066} //namespace armnn