blob: f6a0ee285b94f335aaac91456c7e90b88fd4ff45 [file] [log] [blame]
Matthew Sloyanb63a3112021-09-08 13:05:51 +01001//
2// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "RefConvolution3dWorkload.hpp"
7
8#include "Conv3dImpl.hpp"
9#include "RefWorkloadUtils.hpp"
10
11#include "Profiling.hpp"
12
13namespace armnn
14{
15RefConvolution3dWorkload::RefConvolution3dWorkload(
16 const Convolution3dQueueDescriptor& descriptor, const WorkloadInfo& info)
Finn Williams73c547d2022-02-15 20:47:34 +000017 : RefBaseWorkload<Convolution3dQueueDescriptor>(descriptor, info)
Matthew Sloyanb63a3112021-09-08 13:05:51 +010018{
19 WorkloadInfo detailsInfo;
20 detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
21 detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
Matthew Sloyan5d7b0a32021-10-18 13:07:49 +010022 detailsInfo.m_WeightsTensorInfo = armnn::Optional<armnn::TensorInfo>(info.m_InputTensorInfos[1]);
Matthew Sloyanb63a3112021-09-08 13:05:51 +010023 if (descriptor.m_Parameters.m_BiasEnabled)
24 {
Matthew Sloyan5d7b0a32021-10-18 13:07:49 +010025 detailsInfo.m_BiasTensorInfo = armnn::Optional<armnn::TensorInfo>(info.m_InputTensorInfos[2]);
Matthew Sloyanb63a3112021-09-08 13:05:51 +010026 }
27
28 // Report Profiling Details
29 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("RefConvolution3dWorkload_Construct",
30 descriptor.m_Parameters,
31 detailsInfo,
32 this->GetGuid());
Matthew Sloyan5d7b0a32021-10-18 13:07:49 +010033}
Matthew Sloyanb63a3112021-09-08 13:05:51 +010034
Matthew Sloyanb63a3112021-09-08 13:05:51 +010035void RefConvolution3dWorkload::Execute() const
36{
37 Execute(m_Data.m_Inputs, m_Data.m_Outputs);
38}
39
40void RefConvolution3dWorkload::ExecuteAsync(WorkingMemDescriptor& workingMemDescriptor)
41{
42 Execute(workingMemDescriptor.m_Inputs, workingMemDescriptor.m_Outputs);
43}
44
45void RefConvolution3dWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const
46{
47 ARMNN_SCOPED_PROFILING_EVENT_GUID(Compute::CpuRef, "RefConvolution3dWorkload_Execute", this->GetGuid());
48
49 std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(GetTensorInfo(inputs[0]), inputs[0]->Map());
50 std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]), outputs[0]->Map());
51
52 const TensorShape& inputShape = GetTensorInfo(inputs[0]).GetShape();
53 const TensorShape& outputShape = GetTensorInfo(outputs[0]).GetShape();
54
Finn Williamsd0420cb2022-05-18 13:24:14 +010055 const auto& filterInfo = GetTensorInfo(inputs[1]);
56 std::unique_ptr<Decoder<float>> filterDecoder = MakeDecoder<float>(GetTensorInfo(inputs[1]), inputs[1]->Map());
57 std::unique_ptr<Decoder<float>> biasDecoder;
58
Matthew Sloyan5d7b0a32021-10-18 13:07:49 +010059 if (m_Data.m_Parameters.m_BiasEnabled)
60 {
Finn Williamsd0420cb2022-05-18 13:24:14 +010061 biasDecoder = MakeDecoder<float>(GetTensorInfo(inputs[2]), inputs[2]->Map());
Matthew Sloyan5d7b0a32021-10-18 13:07:49 +010062 }
63
Finn Williamsd0420cb2022-05-18 13:24:14 +010064 Convolve3d(inputShape, *inputDecoder, outputShape, *outputEncoder, filterInfo.GetShape(),
65 *filterDecoder, m_Data.m_Parameters.m_BiasEnabled, biasDecoder.get(),
Matthew Sloyanb63a3112021-09-08 13:05:51 +010066 m_Data.m_Parameters.m_DataLayout,
67 m_Data.m_Parameters.m_PadTop, m_Data.m_Parameters.m_PadLeft, m_Data.m_Parameters.m_PadFront,
68 m_Data.m_Parameters.m_StrideX, m_Data.m_Parameters.m_StrideY, m_Data.m_Parameters.m_StrideZ,
69 m_Data.m_Parameters.m_DilationX, m_Data.m_Parameters.m_DilationY, m_Data.m_Parameters.m_DilationZ);
70}
71
72} //namespace armnn