ArmNN
 25.11
Loading...
Searching...
No Matches
ClBatchToSpaceNdWorkload Class Reference

#include <ClBatchToSpaceNdWorkload.hpp>

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

Public Member Functions

 ClBatchToSpaceNdWorkload (const BatchToSpaceNdQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
virtual void Execute () const override
Public Member Functions inherited from ClBaseWorkload< BatchToSpaceNdQueueDescriptor >
 ClBaseWorkload (const BatchToSpaceNdQueueDescriptor &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< BatchToSpaceNdQueueDescriptor >
 BaseWorkload (const BatchToSpaceNdQueueDescriptor &descriptor, const WorkloadInfo &info)
virtual const std::string & GetName () const override
void PostAllocationConfigure () override
const BatchToSpaceNdQueueDescriptorGetData () const
arm::pipe::ProfilingGuid GetGuid () const final
virtual bool SupportsTensorHandleReplacement () const override
Public Member Functions inherited from IWorkload
virtual ~IWorkload ()
virtual void RegisterDebugCallback (const DebugCallbackFunction &)
virtual armnn::Optional< armnn::MemoryRequirementsGetMemoryRequirements ()

Additional Inherited Members

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

Detailed Description

Definition at line 21 of file ClBatchToSpaceNdWorkload.hpp.

Constructor & Destructor Documentation

◆ ClBatchToSpaceNdWorkload()

ClBatchToSpaceNdWorkload ( const BatchToSpaceNdQueueDescriptor & descriptor,
const WorkloadInfo & info,
const arm_compute::CLCompileContext & clCompileContext )

Definition at line 88 of file ClBatchToSpaceNdWorkload.cpp.

91 : ClBaseWorkload<BatchToSpaceNdQueueDescriptor>(descriptor, info)
92{
93 // Report Profiling Details
94 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClBatchToSpaceWorkload_Construct",
95 descriptor.m_Parameters,
96 info,
97 this->GetGuid());
98
99 m_Data.ValidateInputsOutputs("ClBatchToSpaceNdWorkload", 1, 1);
100
101 arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
102 arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
103
104 arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
105 input.info()->set_data_layout(aclDataLayout);
106 output.info()->set_data_layout(aclDataLayout);
107
108 arm_compute::TensorInfo aclReshapeInputInfo = BuildArmComputeTensorInfo(info.m_InputTensorInfos[0],
109 m_Data.m_Parameters.m_DataLayout);
110 arm_compute::TensorInfo aclReshapeOutputInfo = BuildArmComputeTensorInfo(info.m_OutputTensorInfos[0],
111 m_Data.m_Parameters.m_DataLayout);
112
113 const unsigned int rank = info.m_InputTensorInfos[0].GetNumDimensions();
114 if (rank == 3)
115 {
116 const arm_compute::TensorShape inputShape = input.info()->tensor_shape();
117 const arm_compute::TensorShape outputShape = output.info()->tensor_shape();
118
119 // When a spacial dimension is missing set W to 1
120 if (m_Data.m_Parameters.m_DataLayout == armnn::DataLayout::NHWC)
121 {
122 // In ACL dimensions are right to left: C, W, H, N
123 aclReshapeInputInfo.set_tensor_shape({inputShape.x(), 1, inputShape.y(), inputShape.z()});
124 aclReshapeOutputInfo.set_tensor_shape({outputShape.x(), 1, outputShape.y(), outputShape.z()});
125 }
126 else if (m_Data.m_Parameters.m_DataLayout == armnn::DataLayout::NCHW)
127 {
128 // In ACL dimensions are right to left: W, H, C, N
129 aclReshapeInputInfo.set_tensor_shape({1, inputShape.x(), inputShape.y(), inputShape.z()});
130 aclReshapeOutputInfo.set_tensor_shape({1, outputShape.x(), outputShape.y(), outputShape.z()});
131 }
132 else
133 {
134 throw InvalidArgumentException("Unsupported or unknown DataLayout", CHECK_LOCATION());
135 }
136
137 m_ReshapeInputTensor.allocator()->init(aclReshapeInputInfo);
138 m_ReshapeOutputTensor.allocator()->init(aclReshapeOutputInfo);
139
140 InitialiseArmComputeTensorEmpty(m_ReshapeInputTensor);
141 InitialiseArmComputeTensorEmpty(m_ReshapeOutputTensor);
142
143 m_LayerReshapeInput.reset(new arm_compute::CLReshapeLayer());
144 m_LayerReshapeOutput.reset(new arm_compute::CLReshapeLayer());
145
146 m_LayerReshapeInput->configure(clCompileContext, &input, &m_ReshapeInputTensor);
147 m_LayerReshapeOutput->configure(clCompileContext, &m_ReshapeOutputTensor, &output);
148 }
149
150 // ArmNN blockShape is [H, W] ACl asks for W, H
151 int32_t blockHeight = armnn::numeric_cast<int32_t>(descriptor.m_Parameters.m_BlockShape[0]);
152 int32_t blockWidth = (rank == 3) ? 1 : armnn::numeric_cast<int32_t>(descriptor.m_Parameters.m_BlockShape[1]);
153
154 const arm_compute::CropInfo cropInfo = BuildArmComputeCropInfo(descriptor.m_Parameters);
155
156 {
157 ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClBatchToSpaceNdWorkload_configure");
158 m_Layer.configure(clCompileContext,
159 (rank == 3) ? &m_ReshapeInputTensor : &input,
160 blockWidth,
161 blockHeight,
162 (rank == 3) ? &m_ReshapeOutputTensor : &output,
163 cropInfo);
164 }
165}
#define ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
#define CHECK_LOCATION()
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)

References ARMNN_REPORT_PROFILING_WORKLOAD_DESC, ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID, CHECK_LOCATION, ClBaseWorkload< BatchToSpaceNdQueueDescriptor >::ClBaseWorkload(), armnn::info, BatchToSpaceNdDescriptor::m_BlockShape, BaseWorkload< BatchToSpaceNdQueueDescriptor >::m_Data, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, armnn::NCHW, armnn::NHWC, and armnn::numeric_cast().

Member Function Documentation

◆ Execute()

void Execute ( ) const
overridevirtual

Implements IWorkload.

Definition at line 167 of file ClBatchToSpaceNdWorkload.cpp.

168{
169 ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClBatchToSpaceNdWorkload_Execute");
170 if (m_LayerReshapeInput)
171 {
172 m_LayerReshapeInput->run();
173 }
174 RunClFunction(m_Layer, CHECK_LOCATION());
175 if (m_LayerReshapeOutput)
176 {
177 m_LayerReshapeOutput->run();
178 }
179}
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)

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


The documentation for this class was generated from the following files: