ArmNN
 23.08
RefDepthwiseConvolution2dWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017,2019,2021-2023 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
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 
19  const DepthwiseConvolution2dQueueDescriptor& descriptor, const WorkloadInfo& info)
21 {
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]);
26 
27  if (descriptor.m_Parameters.m_BiasEnabled)
28  {
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 
40 {
42 }
43 
45 {
46  WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data);
47  Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs);
48 }
49 
50 void RefDepthwiseConvolution2dWorkload::Execute(std::vector<ITensorHandle*> inputs,
51  std::vector<ITensorHandle*> outputs) const
52 {
53  ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID("RefDepthwiseConvolution2dWorkload_Execute");
54 
55  const TensorShape& inputShape = GetTensorInfo(inputs[0]).GetShape();
56  const TensorShape& outputShape = GetTensorInfo(outputs[0]).GetShape();
57  const TensorShape& filterShape = GetTensorInfo(inputs[1]).GetShape();
58 
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{};
64  {
65  biasDecoder = MakeDecoder<float>(GetTensorInfo(inputs[2]), inputs[2]->Map());
66  }
67 
68  Convolve(inputShape, *inputDecoder, outputShape, *outputEncoder,
69  filterShape, *filterDecoder, m_Data.m_Parameters.m_BiasEnabled, biasDecoder.get(),
74 }
75 
76 } //namespace armnn
armnn::Optional< armnn::TensorInfo >
armnn::DepthwiseConvolution2dDescriptor::m_BiasEnabled
bool m_BiasEnabled
Enable/disable bias.
Definition: Descriptors.hpp:708
armnn::experimental::ExecutionData::m_Data
void * m_Data
Definition: ExecutionData.hpp:16
armnn::DepthwiseConvolution2dDescriptor::m_DataLayout
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Definition: Descriptors.hpp:710
Profiling.hpp
armnn::DepthwiseConvolution2dDescriptor::m_PadLeft
uint32_t m_PadLeft
Padding left value in the width dimension.
Definition: Descriptors.hpp:692
ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
Definition: RefWorkloadUtils.hpp:22
ResolveType.hpp
ConvImpl.hpp
armnn::DepthwiseConvolution2dDescriptor::m_StrideY
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
Definition: Descriptors.hpp:702
RefDepthwiseConvolution2dWorkload.hpp
armnn::TensorShape
Definition: Tensor.hpp:20
armnn::WorkloadInfo::m_OutputTensorInfos
std::vector< TensorInfo > m_OutputTensorInfos
Definition: WorkloadInfo.hpp:19
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
armnn::DepthwiseConvolution2dDescriptor::m_DilationY
uint32_t m_DilationY
Dilation factor value for height dimension.
Definition: Descriptors.hpp:706
armnn::WorkloadInfo::m_WeightsTensorInfo
Optional< TensorInfo > m_WeightsTensorInfo
Definition: WorkloadInfo.hpp:21
armnn::WorkloadInfo::m_BiasTensorInfo
Optional< TensorInfo > m_BiasTensorInfo
Definition: WorkloadInfo.hpp:22
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
armnn::RefDepthwiseConvolution2dWorkload::ExecuteAsync
void ExecuteAsync(ExecutionData &executionData) override
Definition: RefDepthwiseConvolution2dWorkload.cpp:44
armnn::GetTensorInfo
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
Definition: RefWorkloadUtils.hpp:33
armnn::BoostLogSeverityMapping::info
@ info
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
armnn::DepthwiseConvolution2dQueueDescriptor
Depthwise Convolution 2D layer workload data.
Definition: WorkloadData.hpp:229
ARMNN_REPORT_PROFILING_WORKLOAD_DESC
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
RefWorkloadUtils.hpp
armnn::BaseWorkload< DepthwiseConvolution2dQueueDescriptor >::m_Data
DepthwiseConvolution2dQueueDescriptor m_Data
Definition: Workload.hpp:89
armnn::RefDepthwiseConvolution2dWorkload::Execute
void Execute() const override
Definition: RefDepthwiseConvolution2dWorkload.cpp:39
armnn::TensorInfo::GetShape
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
armnn::WorkloadInfo::m_InputTensorInfos
std::vector< TensorInfo > m_InputTensorInfos
Definition: WorkloadInfo.hpp:18
Decoders.hpp
armnn::LayerType::Map
@ Map
armnn::experimental::WorkingMemDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkingMemDescriptor.hpp:20
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::experimental::WorkingMemDescriptor
Definition: WorkingMemDescriptor.hpp:18
armnn::Convolve
void Convolve(const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, const TensorShape &rFilterShape, Decoder< float > &rFilterDecoder, bool biasEnabled, Decoder< float > *pBiasDecoder, DataLayout dataLayout, unsigned int paddingTop, unsigned int paddingLeft, unsigned int xStride, unsigned int yStride, unsigned int xDilation, unsigned int yDilation, bool depthwise)
Definition: ConvImpl.cpp:71
armnn::DepthwiseConvolution2dDescriptor::m_DilationX
uint32_t m_DilationX
Dilation factor value for width dimension.
Definition: Descriptors.hpp:704
Encoders.hpp
armnn::RefBaseWorkload
Definition: RefBaseWorkload.hpp:13
armnn::RefDepthwiseConvolution2dWorkload::RefDepthwiseConvolution2dWorkload
RefDepthwiseConvolution2dWorkload(const DepthwiseConvolution2dQueueDescriptor &descriptor, const WorkloadInfo &info)
Definition: RefDepthwiseConvolution2dWorkload.cpp:18
armnn::experimental::WorkingMemDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkingMemDescriptor.hpp:21
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26
armnn::experimental::ExecutionData
Definition: ExecutionData.hpp:14
armnn::DepthwiseConvolution2dDescriptor::m_StrideX
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
Definition: Descriptors.hpp:700
armnn::DepthwiseConvolution2dDescriptor::m_PadTop
uint32_t m_PadTop
Padding top value in the height dimension.
Definition: Descriptors.hpp:696