ArmNN
 21.11
RefConvolution3dWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 #include "Conv3dImpl.hpp"
9 #include "RefWorkloadUtils.hpp"
10 
11 #include "Profiling.hpp"
12 
13 namespace armnn
14 {
16  const Convolution3dQueueDescriptor& descriptor, const WorkloadInfo& info)
17  : BaseWorkload<Convolution3dQueueDescriptor>(descriptor, info)
18 {
19  WorkloadInfo detailsInfo;
20  detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
21  detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
23  if (descriptor.m_Parameters.m_BiasEnabled)
24  {
26  }
27 
28  // Report Profiling Details
29  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("RefConvolution3dWorkload_Construct",
30  descriptor.m_Parameters,
31  detailsInfo,
32  this->GetGuid());
33 }
34 
36 {
38 }
39 
40 void RefConvolution3dWorkload::PostAllocationConfigure(std::vector<ITensorHandle*> inputs,
41  std::vector<ITensorHandle*> outputs)
42 {
43  IgnoreUnused(outputs);
44  const TensorInfo& rFilterInfo = GetTensorInfo(inputs[1]);
45  m_FilterShape = rFilterInfo.GetShape();
46  m_FilterDecoder = MakeDecoder<float>(rFilterInfo);
47 
49  {
50  const TensorInfo& biasInfo = GetTensorInfo(inputs[2]);
51  m_BiasDecoder = MakeDecoder<float>(biasInfo);
52  }
53 }
54 
56 {
58 }
59 
61 {
62  PostAllocationConfigure(workingMemDescriptor.m_Inputs, workingMemDescriptor.m_Outputs);
63 
64  Execute(workingMemDescriptor.m_Inputs, workingMemDescriptor.m_Outputs);
65 }
66 
67 void RefConvolution3dWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const
68 {
69  ARMNN_SCOPED_PROFILING_EVENT_GUID(Compute::CpuRef, "RefConvolution3dWorkload_Execute", this->GetGuid());
70 
71  std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(GetTensorInfo(inputs[0]), inputs[0]->Map());
72  std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]), outputs[0]->Map());
73 
74  const TensorShape& inputShape = GetTensorInfo(inputs[0]).GetShape();
75  const TensorShape& outputShape = GetTensorInfo(outputs[0]).GetShape();
76 
77  m_FilterDecoder->Reset(inputs[1]->Map());
79  {
80  m_BiasDecoder->Reset(inputs[2]->Map());
81  }
82 
83  Convolve3d(inputShape, *inputDecoder, outputShape, *outputEncoder, m_FilterShape,
84  *m_FilterDecoder, m_Data.m_Parameters.m_BiasEnabled, m_BiasDecoder.get(),
89 }
90 
91 } //namespace armnn
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
CPU Execution: Reference C++ kernels.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
bool m_BiasEnabled
Enable/disable bias.
Copyright (c) 2021 ARM Limited and Contributors.
void IgnoreUnused(Ts &&...)
uint32_t m_DilationX
Dilation along x axis.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
std::vector< TensorInfo > m_InputTensorInfos
void ExecuteAsync(WorkingMemDescriptor &workingMemDescriptor) override
std::vector< TensorInfo > m_OutputTensorInfos
uint32_t m_PadFront
Padding front value in the depth dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
#define ARMNN_SCOPED_PROFILING_EVENT_GUID(backendId, name, guid)
Definition: Profiling.hpp:223
profiling::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:55
Optional< TensorInfo > m_BiasTensorInfo
DataLayout m_DataLayout
The data layout to be used (NDHWC, NCDHW).
std::vector< ITensorHandle * > m_Outputs
uint32_t m_PadTop
Padding top value in the height dimension.
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
Contains information about TensorInfos of a layer.
std::vector< ITensorHandle * > m_Inputs
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
uint32_t m_DilationZ
Dilation along z axis.
RefConvolution3dWorkload(const Convolution3dQueueDescriptor &descriptor, const WorkloadInfo &info)
uint32_t m_StrideZ
Stride value when proceeding through input for the depth dimension.
Optional< TensorInfo > m_WeightsTensorInfo
uint32_t m_DilationY
Dilation along y axis.
void Convolve3d(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 paddingFront, unsigned int xStride, unsigned int yStride, unsigned int zStride, unsigned int xDilation, unsigned int yDilation, unsigned int zDilation)
Definition: Conv3dImpl.cpp:11