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; |
| 25 | detailsInfo.m_WeightsTensorInfo = armnn::Optional<armnn::TensorInfo>(info.m_InputTensorInfos[1]); |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 26 | |
| 27 | if (descriptor.m_Parameters.m_BiasEnabled) |
| 28 | { |
Cathal Corbett | 0690265 | 2022-04-14 17:55:11 +0100 | [diff] [blame] | 29 | detailsInfo.m_BiasTensorInfo = armnn::Optional<armnn::TensorInfo>(info.m_InputTensorInfos[2]); |
| 30 | } |
| 31 | |
| 32 | // Report Profiling Details |
| 33 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("RefDepthwiseConvolution2dWorkload_Construct", |
| 34 | descriptor.m_Parameters, |
| 35 | detailsInfo, |
| 36 | this->GetGuid()); |
| 37 | } |
| 38 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 39 | void RefDepthwiseConvolution2dWorkload::Execute() const |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 40 | { |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 41 | Execute(m_Data.m_Inputs, m_Data.m_Outputs); |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 42 | } |
| 43 | |
Matthew Sloyan | 2d213a7 | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 44 | void RefDepthwiseConvolution2dWorkload::ExecuteAsync(ExecutionData& executionData) |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 45 | { |
Matthew Sloyan | 2d213a7 | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 46 | WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data); |
| 47 | Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs); |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | void RefDepthwiseConvolution2dWorkload::Execute(std::vector<ITensorHandle*> inputs, |
| 51 | std::vector<ITensorHandle*> outputs) const |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 52 | { |
Mike Kelly | 7cbe781 | 2023-07-25 17:37:33 +0100 | [diff] [blame] | 53 | ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID("RefDepthwiseConvolution2dWorkload_Execute"); |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 54 | |
Teresa Charlin | 60692ce | 2022-05-11 17:01:50 +0100 | [diff] [blame] | 55 | const TensorShape& inputShape = GetTensorInfo(inputs[0]).GetShape(); |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 56 | const TensorShape& outputShape = GetTensorInfo(outputs[0]).GetShape(); |
Teresa Charlin | 60692ce | 2022-05-11 17:01:50 +0100 | [diff] [blame] | 57 | const TensorShape& filterShape = GetTensorInfo(inputs[1]).GetShape(); |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 58 | |
Teresa Charlin | 60692ce | 2022-05-11 17:01:50 +0100 | [diff] [blame] | 59 | std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(GetTensorInfo(inputs[0]), inputs[0]->Map()); |
| 60 | std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]), outputs[0]->Map()); |
| 61 | std::unique_ptr<Decoder<float>> filterDecoder = MakeDecoder<float>(GetTensorInfo(inputs[1]), inputs[1]->Map()); |
| 62 | std::unique_ptr<Decoder<float>> biasDecoder{}; |
Cathal Corbett | 0690265 | 2022-04-14 17:55:11 +0100 | [diff] [blame] | 63 | if (m_Data.m_Parameters.m_BiasEnabled) |
| 64 | { |
Teresa Charlin | 60692ce | 2022-05-11 17:01:50 +0100 | [diff] [blame] | 65 | biasDecoder = MakeDecoder<float>(GetTensorInfo(inputs[2]), inputs[2]->Map()); |
Cathal Corbett | 0690265 | 2022-04-14 17:55:11 +0100 | [diff] [blame] | 66 | } |
| 67 | |
Teresa Charlin | 60692ce | 2022-05-11 17:01:50 +0100 | [diff] [blame] | 68 | Convolve(inputShape, *inputDecoder, outputShape, *outputEncoder, |
| 69 | filterShape, *filterDecoder, m_Data.m_Parameters.m_BiasEnabled, biasDecoder.get(), |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 70 | m_Data.m_Parameters.m_DataLayout, m_Data.m_Parameters.m_PadTop, m_Data.m_Parameters.m_PadLeft, |
| 71 | m_Data.m_Parameters.m_StrideX, m_Data.m_Parameters.m_StrideY, |
| 72 | m_Data.m_Parameters.m_DilationX, |
| 73 | m_Data.m_Parameters.m_DilationY, true); |
| 74 | } |
| 75 | |
| 76 | } //namespace armnn |