Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 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 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 44 | void RefDepthwiseConvolution2dWorkload::ExecuteAsync(WorkingMemDescriptor &workingMemDescriptor) |
| 45 | { |
| 46 | Execute(workingMemDescriptor.m_Inputs, workingMemDescriptor.m_Outputs); |
| 47 | } |
| 48 | |
| 49 | void RefDepthwiseConvolution2dWorkload::Execute(std::vector<ITensorHandle*> inputs, |
| 50 | std::vector<ITensorHandle*> outputs) const |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 51 | { |
| 52 | ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefDepthwiseConvolution2dWorkload_Execute"); |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 53 | |
Teresa Charlin | 60692ce | 2022-05-11 17:01:50 +0100 | [diff] [blame] | 54 | const TensorShape& inputShape = GetTensorInfo(inputs[0]).GetShape(); |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 55 | const TensorShape& outputShape = GetTensorInfo(outputs[0]).GetShape(); |
Teresa Charlin | 60692ce | 2022-05-11 17:01:50 +0100 | [diff] [blame] | 56 | const TensorShape& filterShape = GetTensorInfo(inputs[1]).GetShape(); |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 57 | |
Teresa Charlin | 60692ce | 2022-05-11 17:01:50 +0100 | [diff] [blame] | 58 | std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(GetTensorInfo(inputs[0]), inputs[0]->Map()); |
| 59 | std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]), outputs[0]->Map()); |
| 60 | std::unique_ptr<Decoder<float>> filterDecoder = MakeDecoder<float>(GetTensorInfo(inputs[1]), inputs[1]->Map()); |
| 61 | std::unique_ptr<Decoder<float>> biasDecoder{}; |
Cathal Corbett | 0690265 | 2022-04-14 17:55:11 +0100 | [diff] [blame] | 62 | if (m_Data.m_Parameters.m_BiasEnabled) |
| 63 | { |
Teresa Charlin | 60692ce | 2022-05-11 17:01:50 +0100 | [diff] [blame] | 64 | biasDecoder = MakeDecoder<float>(GetTensorInfo(inputs[2]), inputs[2]->Map()); |
Cathal Corbett | 0690265 | 2022-04-14 17:55:11 +0100 | [diff] [blame] | 65 | } |
| 66 | |
Teresa Charlin | 60692ce | 2022-05-11 17:01:50 +0100 | [diff] [blame] | 67 | Convolve(inputShape, *inputDecoder, outputShape, *outputEncoder, |
| 68 | filterShape, *filterDecoder, m_Data.m_Parameters.m_BiasEnabled, biasDecoder.get(), |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 69 | m_Data.m_Parameters.m_DataLayout, m_Data.m_Parameters.m_PadTop, m_Data.m_Parameters.m_PadLeft, |
| 70 | m_Data.m_Parameters.m_StrideX, m_Data.m_Parameters.m_StrideY, |
| 71 | m_Data.m_Parameters.m_DilationX, |
| 72 | m_Data.m_Parameters.m_DilationY, true); |
| 73 | } |
| 74 | |
| 75 | } //namespace armnn |