ArmNN
 24.02
ClSpaceToBatchNdWorkload Class Reference

#include <ClSpaceToBatchNdWorkload.hpp>

Inheritance diagram for ClSpaceToBatchNdWorkload:
[legend]
Collaboration diagram for ClSpaceToBatchNdWorkload:
[legend]

Public Member Functions

 ClSpaceToBatchNdWorkload (const SpaceToBatchNdQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
 
virtual void Execute () const override
 
- Public Member Functions inherited from ClBaseWorkload< SpaceToBatchNdQueueDescriptor >
 ClBaseWorkload (const SpaceToBatchNdQueueDescriptor &descriptor, const WorkloadInfo &info)
 
void ReplaceInputTensorHandle (ITensorHandle *tensorHandle, unsigned int slot) override
 
void ReplaceOutputTensorHandle (ITensorHandle *tensorHandle, unsigned int slot) override
 
- Public Member Functions inherited from BaseWorkload< SpaceToBatchNdQueueDescriptor >
 BaseWorkload (const SpaceToBatchNdQueueDescriptor &descriptor, const WorkloadInfo &info)
 
virtual const std::string & GetName () const override
 
void ExecuteAsync (ExecutionData &executionData) override
 
void PostAllocationConfigure () override
 
const SpaceToBatchNdQueueDescriptorGetData () const
 
arm::pipe::ProfilingGuid GetGuid () const final
 
virtual bool SupportsTensorHandleReplacement () const override
 
- Public Member Functions inherited from IWorkload
virtual ~IWorkload ()
 
virtual arm::pipe::ProfilingGuid GetGuid () const =0
 
virtual bool SupportsTensorHandleReplacement () const =0
 
virtual const std::string & GetName () const =0
 
virtual void RegisterDebugCallback (const DebugCallbackFunction &)
 
virtual armnn::Optional< armnn::MemoryRequirementsGetMemoryRequirements ()
 

Additional Inherited Members

- Protected Member Functions inherited from ClBaseWorkload< SpaceToBatchNdQueueDescriptor >
virtual void Reconfigure ()
 
- Protected Attributes inherited from BaseWorkload< SpaceToBatchNdQueueDescriptor >
SpaceToBatchNdQueueDescriptor m_Data
 
const arm::pipe::ProfilingGuid m_Guid
 
const std::string m_Name
 

Detailed Description

Definition at line 21 of file ClSpaceToBatchNdWorkload.hpp.

Constructor & Destructor Documentation

◆ ClSpaceToBatchNdWorkload()

ClSpaceToBatchNdWorkload ( const SpaceToBatchNdQueueDescriptor descriptor,
const WorkloadInfo info,
const arm_compute::CLCompileContext &  clCompileContext 
)

Definition at line 93 of file ClSpaceToBatchNdWorkload.cpp.

96  : ClBaseWorkload<SpaceToBatchNdQueueDescriptor>(descriptor, info)
97 {
98  // Report Profiling Details
99  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClSpaceToBatchNdWorkload_Construct",
100  descriptor.m_Parameters,
101  info,
102  this->GetGuid());
103 
104  m_Data.ValidateInputsOutputs("ClSpaceToBatchNdWorkload", 1, 1);
105 
106  arm_compute::ICLTensor& input = PolymorphicPointerDowncast<IClTensorHandle>(m_Data.m_Inputs[0])->GetTensor();
107  arm_compute::ICLTensor& output = PolymorphicPointerDowncast<IClTensorHandle>(m_Data.m_Outputs[0])->GetTensor();
108 
109  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
110  input.info()->set_data_layout(aclDataLayout);
111  output.info()->set_data_layout(aclDataLayout);
112 
113  arm_compute::TensorInfo aclReshapeInputInfo = BuildArmComputeTensorInfo(info.m_InputTensorInfos[0],
115  arm_compute::TensorInfo aclReshapeOutputInfo = BuildArmComputeTensorInfo(info.m_OutputTensorInfos[0],
117 
118  const unsigned int rank = info.m_InputTensorInfos[0].GetNumDimensions();
119  if (rank == 3)
120  {
121  const arm_compute::TensorShape inputShape = input.info()->tensor_shape();
122  const arm_compute::TensorShape outputShape = output.info()->tensor_shape();
123 
124  // When a spacial dimension is missing set W to 1
126  {
127  // In ACL dimensions are right to left: C, W, H, N
128  aclReshapeInputInfo.set_tensor_shape({inputShape.x(), 1, inputShape.y(), inputShape.z()});
129  aclReshapeOutputInfo.set_tensor_shape({outputShape.x(), 1, outputShape.y(), outputShape.z()});
130  }
132  {
133  // In ACL dimensions are right to left: W, H, C, N
134  aclReshapeInputInfo.set_tensor_shape({1, inputShape.x(), inputShape.y(), inputShape.z()});
135  aclReshapeOutputInfo.set_tensor_shape({1, outputShape.x(), outputShape.y(), outputShape.z()});
136  }
137  else
138  {
139  throw InvalidArgumentException("Unsupported or unknown DataLayout", CHECK_LOCATION());
140  }
141 
142  m_ReshapeInputTensor.allocator()->init(aclReshapeInputInfo);
143  m_ReshapeOutputTensor.allocator()->init(aclReshapeOutputInfo);
144 
145  InitialiseArmComputeTensorEmpty(m_ReshapeInputTensor);
146  InitialiseArmComputeTensorEmpty(m_ReshapeOutputTensor);
147 
148  m_LayerReshapeInput.reset(new arm_compute::CLReshapeLayer());
149  m_LayerReshapeOutput.reset(new arm_compute::CLReshapeLayer());
150 
151  m_LayerReshapeInput->configure(clCompileContext, &input, &m_ReshapeInputTensor);
152  m_LayerReshapeOutput->configure(clCompileContext, &m_ReshapeOutputTensor, &output);
153  }
154 
155  // ArmNN blockShape is [H, W] ACl asks for W, H
156  int32_t blockHeight = armnn::numeric_cast<int32_t>(m_Data.m_Parameters.m_BlockShape[0]);
157  int32_t blockWidth = (rank == 3) ? 1: armnn::numeric_cast<int32_t>(descriptor.m_Parameters.m_BlockShape[1]);
158 
159  unsigned int padLeft = (rank == 3) ? 0 : descriptor.m_Parameters.m_PadList[1].first;
160  unsigned int padRight = (rank == 3) ? 0 : descriptor.m_Parameters.m_PadList[1].second;
161  arm_compute::Size2D paddingLeftTop = BuildArmComputeSize2D(padLeft,
162  descriptor.m_Parameters.m_PadList[0].first);
163  arm_compute::Size2D paddingRightBottom = BuildArmComputeSize2D(padRight,
164  descriptor.m_Parameters.m_PadList[0].second);
165 
166  {
167  ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClSpaceToBatchNdWorkload_configure");
168  m_Layer.configure(clCompileContext,
169  rank == 3 ? &m_ReshapeInputTensor : &input,
170  blockWidth,
171  blockHeight,
172  paddingLeftTop,
173  paddingRightBottom,
174  rank == 3 ? &m_ReshapeOutputTensor : &output);
175  }
176 }

References ARMNN_REPORT_PROFILING_WORKLOAD_DESC, armnn::info, BaseWorkload< SpaceToBatchNdQueueDescriptor >::m_Data, QueueDescriptor::m_Inputs, QueueDescriptor::m_Outputs, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, and QueueDescriptor::ValidateInputsOutputs().

Member Function Documentation

◆ Execute()

void Execute ( ) const
overridevirtual

Implements IWorkload.

Definition at line 178 of file ClSpaceToBatchNdWorkload.cpp.

179 {
180  ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClSpaceToBatchNdWorkload_Execute");
181  if (m_LayerReshapeInput)
182  {
183  m_LayerReshapeInput->run();
184  }
186  if (m_LayerReshapeOutput)
187  {
188  m_LayerReshapeOutput->run();
189  }
190 }

References ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID, CHECK_LOCATION, and armnn::RunClFunction().


The documentation for this class was generated from the following files:
armnn::DataLayout
DataLayout
Definition: Types.hpp:62
armnn::SpaceToBatchNdDescriptor::m_DataLayout
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Definition: Descriptors.hpp:1071
armnn::DataLayout::NHWC
@ NHWC
armnn::QueueDescriptor::ValidateInputsOutputs
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Definition: WorkloadData.cpp:446
m_Layer
IConnectableLayer * m_Layer
Definition: SubgraphViewSelector.cpp:247
CHECK_LOCATION
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203
armnn::SpaceToBatchNdDescriptor::m_BlockShape
std::vector< unsigned int > m_BlockShape
Block shape value.
Definition: Descriptors.hpp:1066
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
Definition: ClWorkloadUtils.hpp:36
armnn::BoostLogSeverityMapping::info
@ info
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
ARMNN_REPORT_PROFILING_WORKLOAD_DESC
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
armnn::BaseWorkload< SpaceToBatchNdQueueDescriptor >::m_Data
SpaceToBatchNdQueueDescriptor m_Data
Definition: Workload.hpp:89
armnn::RunClFunction
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
Definition: ClWorkloadUtils.hpp:168
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26
armnn::DataLayout::NCHW
@ NCHW