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

#include <NeonBatchToSpaceNdWorkload.hpp>

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

Public Member Functions

 NeonBatchToSpaceNdWorkload (const BatchToSpaceNdQueueDescriptor &descriptor, const WorkloadInfo &info)
virtual void Execute () const override
Public Member Functions inherited from NeonBaseWorkload< BatchToSpaceNdQueueDescriptor >
 NeonBaseWorkload (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 NeonBaseWorkload< 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 NeonBatchToSpaceNdWorkload.hpp.

Constructor & Destructor Documentation

◆ NeonBatchToSpaceNdWorkload()

Definition at line 86 of file NeonBatchToSpaceNdWorkload.cpp.

88 : NeonBaseWorkload<BatchToSpaceNdQueueDescriptor>(descriptor, info)
89{
90 // Report Profiling Details
91 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonBatchToSpaceWorkload_Construct",
92 descriptor.m_Parameters,
93 info,
94 this->GetGuid());
95
96 m_Data.ValidateInputsOutputs("NeonBatchToSpaceNdWorkload", 1, 1);
97
98 arm_compute::ITensor& input = PolymorphicPointerDowncast<IAclTensorHandle>(m_Data.m_Inputs[0])->GetTensor();
99 arm_compute::ITensor& output = PolymorphicPointerDowncast<IAclTensorHandle>(m_Data.m_Outputs[0])->GetTensor();
100
101 arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
102 input.info()->set_data_layout(aclDataLayout);
103 output.info()->set_data_layout(aclDataLayout);
104
105 arm_compute::TensorInfo aclReshapeInputInfo = BuildArmComputeTensorInfo(info.m_InputTensorInfos[0],
106 m_Data.m_Parameters.m_DataLayout);
107 arm_compute::TensorInfo aclReshapeOutputInfo = BuildArmComputeTensorInfo(info.m_OutputTensorInfos[0],
108 m_Data.m_Parameters.m_DataLayout);
109
110 const unsigned int rank = info.m_InputTensorInfos[0].GetNumDimensions();
111 if (rank == 3)
112 {
113 const arm_compute::TensorShape inputShape = input.info()->tensor_shape();
114 const arm_compute::TensorShape outputShape = output.info()->tensor_shape();
115
116 // When a spacial dimension is missing set W to 1
117 if (m_Data.m_Parameters.m_DataLayout == armnn::DataLayout::NHWC)
118 {
119 // In ACL dimensions are right to left: C, W, H, N
120 aclReshapeInputInfo.set_tensor_shape({inputShape.x(), 1, inputShape.y(), inputShape.z()});
121 aclReshapeOutputInfo.set_tensor_shape({outputShape.x(), 1, outputShape.y(), outputShape.z()});
122 }
123 else if (m_Data.m_Parameters.m_DataLayout == armnn::DataLayout::NCHW)
124 {
125 // In ACL dimensions are right to left: W, H, C, N
126 aclReshapeInputInfo.set_tensor_shape({1, inputShape.x(), inputShape.y(), inputShape.z()});
127 aclReshapeOutputInfo.set_tensor_shape({1, outputShape.x(), outputShape.y(), outputShape.z()});
128 }
129 else
130 {
131 throw InvalidArgumentException("Unsupported or unknown DataLayout", CHECK_LOCATION());
132 }
133
134 m_ReshapeInputTensor.allocator()->init(aclReshapeInputInfo);
135 m_ReshapeOutputTensor.allocator()->init(aclReshapeOutputInfo);
136
137 InitialiseArmComputeTensorEmpty(m_ReshapeInputTensor);
138 InitialiseArmComputeTensorEmpty(m_ReshapeOutputTensor);
139
140 m_LayerReshapeInput.reset(new arm_compute::NEReshapeLayer());
141 m_LayerReshapeOutput.reset(new arm_compute::NEReshapeLayer());
142
143 m_LayerReshapeInput->configure(&input, &m_ReshapeInputTensor);
144 m_LayerReshapeOutput->configure(&m_ReshapeOutputTensor, &output);
145 }
146
147 // ArmNN blockShape is [H, W] ACl asks for W, H
148 int32_t blockHeight = armnn::numeric_cast<int32_t>(descriptor.m_Parameters.m_BlockShape[0]);
149 int32_t blockWidth = (rank == 3) ? 1 : armnn::numeric_cast<int32_t>(descriptor.m_Parameters.m_BlockShape[1]);
150
151 const arm_compute::CropInfo cropInfo = BuildArmComputeCropInfo(descriptor.m_Parameters, rank);
152
153 m_Layer.reset(new arm_compute::NEBatchToSpaceLayer());
154 m_Layer->configure(rank == 3 ? &m_ReshapeInputTensor : &input,
155 blockWidth,
156 blockHeight,
157 rank == 3 ? &m_ReshapeOutputTensor : &output,
158 cropInfo);
159 m_Layer->prepare();
160}
#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, CHECK_LOCATION, armnn::info, BatchToSpaceNdDescriptor::m_BlockShape, BaseWorkload< BatchToSpaceNdQueueDescriptor >::m_Data, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, armnn::NCHW, NeonBaseWorkload< BatchToSpaceNdQueueDescriptor >::NeonBaseWorkload(), armnn::NHWC, armnn::numeric_cast(), and armnn::PolymorphicPointerDowncast().

Member Function Documentation

◆ Execute()

void Execute ( ) const
overridevirtual

Implements IWorkload.

Definition at line 162 of file NeonBatchToSpaceNdWorkload.cpp.

163{
164 ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID("NeonBatchToSpaceNdWorkload_Execute");
165 if (m_LayerReshapeInput)
166 {
167 m_LayerReshapeInput->run();
168 }
169 if (m_Layer)
170 {
171 m_Layer->run();
172 }
173 if (m_LayerReshapeOutput)
174 {
175 m_LayerReshapeOutput->run();
176 }
177}
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.

References ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID.


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