Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 1 | // |
Mike Kelly | 7cbe781 | 2023-07-25 17:37:33 +0100 | [diff] [blame] | 2 | // Copyright © 2021-2023 Arm Ltd and Contributors. All rights reserved. |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 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 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | RefConvolution3dWorkload::RefConvolution3dWorkload( |
| 16 | const Convolution3dQueueDescriptor& descriptor, const WorkloadInfo& info) |
Finn Williams | 73c547d | 2022-02-15 20:47:34 +0000 | [diff] [blame] | 17 | : RefBaseWorkload<Convolution3dQueueDescriptor>(descriptor, info) |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 18 | { |
| 19 | WorkloadInfo detailsInfo; |
| 20 | detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos; |
| 21 | detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos; |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 22 | |
| 23 | // Report Profiling Details |
| 24 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("RefConvolution3dWorkload_Construct", |
| 25 | descriptor.m_Parameters, |
| 26 | detailsInfo, |
| 27 | this->GetGuid()); |
Matthew Sloyan | 5d7b0a3 | 2021-10-18 13:07:49 +0100 | [diff] [blame] | 28 | } |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 29 | |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 30 | void RefConvolution3dWorkload::Execute() const |
| 31 | { |
| 32 | Execute(m_Data.m_Inputs, m_Data.m_Outputs); |
| 33 | } |
| 34 | |
Matthew Sloyan | 2d213a7 | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 35 | void RefConvolution3dWorkload::ExecuteAsync(ExecutionData& executionData) |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 36 | { |
Matthew Sloyan | 2d213a7 | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 37 | WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data); |
| 38 | Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs); |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | void RefConvolution3dWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const |
| 42 | { |
Mike Kelly | 7cbe781 | 2023-07-25 17:37:33 +0100 | [diff] [blame] | 43 | ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID("RefConvolution3dWorkload_Execute"); |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 44 | |
| 45 | std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(GetTensorInfo(inputs[0]), inputs[0]->Map()); |
| 46 | std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]), outputs[0]->Map()); |
| 47 | |
| 48 | const TensorShape& inputShape = GetTensorInfo(inputs[0]).GetShape(); |
| 49 | const TensorShape& outputShape = GetTensorInfo(outputs[0]).GetShape(); |
| 50 | |
Finn Williams | d0420cb | 2022-05-18 13:24:14 +0100 | [diff] [blame] | 51 | const auto& filterInfo = GetTensorInfo(inputs[1]); |
| 52 | std::unique_ptr<Decoder<float>> filterDecoder = MakeDecoder<float>(GetTensorInfo(inputs[1]), inputs[1]->Map()); |
| 53 | std::unique_ptr<Decoder<float>> biasDecoder; |
| 54 | |
Matthew Sloyan | 5d7b0a3 | 2021-10-18 13:07:49 +0100 | [diff] [blame] | 55 | if (m_Data.m_Parameters.m_BiasEnabled) |
| 56 | { |
Finn Williams | d0420cb | 2022-05-18 13:24:14 +0100 | [diff] [blame] | 57 | biasDecoder = MakeDecoder<float>(GetTensorInfo(inputs[2]), inputs[2]->Map()); |
Matthew Sloyan | 5d7b0a3 | 2021-10-18 13:07:49 +0100 | [diff] [blame] | 58 | } |
| 59 | |
Finn Williams | d0420cb | 2022-05-18 13:24:14 +0100 | [diff] [blame] | 60 | Convolve3d(inputShape, *inputDecoder, outputShape, *outputEncoder, filterInfo.GetShape(), |
| 61 | *filterDecoder, m_Data.m_Parameters.m_BiasEnabled, biasDecoder.get(), |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 62 | m_Data.m_Parameters.m_DataLayout, |
| 63 | m_Data.m_Parameters.m_PadTop, m_Data.m_Parameters.m_PadLeft, m_Data.m_Parameters.m_PadFront, |
| 64 | m_Data.m_Parameters.m_StrideX, m_Data.m_Parameters.m_StrideY, m_Data.m_Parameters.m_StrideZ, |
| 65 | m_Data.m_Parameters.m_DilationX, m_Data.m_Parameters.m_DilationY, m_Data.m_Parameters.m_DilationZ); |
| 66 | } |
| 67 | |
| 68 | } //namespace armnn |