Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 1 | // |
Mike Kelly | 7cbe781 | 2023-07-25 17:37:33 +0100 | [diff] [blame] | 2 | // Copyright © 2017,2019,2021-2023 Arm Ltd and Contributors. All rights reserved. |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "RefDepthwiseConvolution2dWorkload.hpp" |
| 7 | |
| 8 | #include "ConvImpl.hpp" |
| 9 | #include "RefWorkloadUtils.hpp" |
| 10 | #include "Decoders.hpp" |
| 11 | #include "Encoders.hpp" |
| 12 | #include "Profiling.hpp" |
| 13 | #include <ResolveType.hpp> |
| 14 | |
| 15 | namespace armnn |
| 16 | { |
| 17 | |
| 18 | RefDepthwiseConvolution2dWorkload::RefDepthwiseConvolution2dWorkload( |
| 19 | const DepthwiseConvolution2dQueueDescriptor& descriptor, const WorkloadInfo& info) |
Finn Williams | 73c547d | 2022-02-15 20:47:34 +0000 | [diff] [blame] | 20 | : RefBaseWorkload<DepthwiseConvolution2dQueueDescriptor>(descriptor, info) |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 21 | { |
Cathal Corbett | 0690265 | 2022-04-14 17:55:11 +0100 | [diff] [blame] | 22 | WorkloadInfo detailsInfo; |
| 23 | detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos; |
| 24 | detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos; |
Cathal Corbett | 0690265 | 2022-04-14 17:55:11 +0100 | [diff] [blame] | 25 | |
| 26 | // Report Profiling Details |
| 27 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("RefDepthwiseConvolution2dWorkload_Construct", |
| 28 | descriptor.m_Parameters, |
| 29 | detailsInfo, |
| 30 | this->GetGuid()); |
| 31 | } |
| 32 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 33 | void RefDepthwiseConvolution2dWorkload::Execute() const |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 34 | { |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 35 | Execute(m_Data.m_Inputs, m_Data.m_Outputs); |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 36 | } |
| 37 | |
Matthew Sloyan | 2d213a7 | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 38 | void RefDepthwiseConvolution2dWorkload::ExecuteAsync(ExecutionData& executionData) |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 39 | { |
Matthew Sloyan | 2d213a7 | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 40 | WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data); |
| 41 | Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs); |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | void RefDepthwiseConvolution2dWorkload::Execute(std::vector<ITensorHandle*> inputs, |
| 45 | std::vector<ITensorHandle*> outputs) const |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 46 | { |
Mike Kelly | 7cbe781 | 2023-07-25 17:37:33 +0100 | [diff] [blame] | 47 | ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID("RefDepthwiseConvolution2dWorkload_Execute"); |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 48 | |
Teresa Charlin | 60692ce | 2022-05-11 17:01:50 +0100 | [diff] [blame] | 49 | const TensorShape& inputShape = GetTensorInfo(inputs[0]).GetShape(); |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 50 | const TensorShape& outputShape = GetTensorInfo(outputs[0]).GetShape(); |
Teresa Charlin | 60692ce | 2022-05-11 17:01:50 +0100 | [diff] [blame] | 51 | const TensorShape& filterShape = GetTensorInfo(inputs[1]).GetShape(); |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 52 | |
Teresa Charlin | 60692ce | 2022-05-11 17:01:50 +0100 | [diff] [blame] | 53 | std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(GetTensorInfo(inputs[0]), inputs[0]->Map()); |
| 54 | std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]), outputs[0]->Map()); |
| 55 | std::unique_ptr<Decoder<float>> filterDecoder = MakeDecoder<float>(GetTensorInfo(inputs[1]), inputs[1]->Map()); |
| 56 | std::unique_ptr<Decoder<float>> biasDecoder{}; |
Cathal Corbett | 0690265 | 2022-04-14 17:55:11 +0100 | [diff] [blame] | 57 | if (m_Data.m_Parameters.m_BiasEnabled) |
| 58 | { |
Teresa Charlin | 60692ce | 2022-05-11 17:01:50 +0100 | [diff] [blame] | 59 | biasDecoder = MakeDecoder<float>(GetTensorInfo(inputs[2]), inputs[2]->Map()); |
Cathal Corbett | 0690265 | 2022-04-14 17:55:11 +0100 | [diff] [blame] | 60 | } |
| 61 | |
Teresa Charlin | 60692ce | 2022-05-11 17:01:50 +0100 | [diff] [blame] | 62 | Convolve(inputShape, *inputDecoder, outputShape, *outputEncoder, |
| 63 | filterShape, *filterDecoder, m_Data.m_Parameters.m_BiasEnabled, biasDecoder.get(), |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 64 | m_Data.m_Parameters.m_DataLayout, m_Data.m_Parameters.m_PadTop, m_Data.m_Parameters.m_PadLeft, |
| 65 | m_Data.m_Parameters.m_StrideX, m_Data.m_Parameters.m_StrideY, |
| 66 | m_Data.m_Parameters.m_DilationX, |
| 67 | m_Data.m_Parameters.m_DilationY, true); |
| 68 | } |
| 69 | |
| 70 | } //namespace armnn |