ArmNN
 24.02
NeonBatchNormalizationWorkload Class Reference

#include <NeonBatchNormalizationWorkload.hpp>

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

Public Member Functions

 NeonBatchNormalizationWorkload (const BatchNormalizationQueueDescriptor &descriptor, const WorkloadInfo &info)
 
virtual void Execute () const override
 
- Public Member Functions inherited from NeonBaseWorkload< BatchNormalizationQueueDescriptor >
 NeonBaseWorkload (const BatchNormalizationQueueDescriptor &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< BatchNormalizationQueueDescriptor >
 BaseWorkload (const BatchNormalizationQueueDescriptor &descriptor, const WorkloadInfo &info)
 
virtual const std::string & GetName () const override
 
void ExecuteAsync (ExecutionData &executionData) override
 
void PostAllocationConfigure () override
 
const BatchNormalizationQueueDescriptorGetData () 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 NeonBaseWorkload< BatchNormalizationQueueDescriptor >
virtual void Reconfigure ()
 
- Protected Attributes inherited from BaseWorkload< BatchNormalizationQueueDescriptor >
BatchNormalizationQueueDescriptor m_Data
 
const arm::pipe::ProfilingGuid m_Guid
 
const std::string m_Name
 

Detailed Description

Definition at line 27 of file NeonBatchNormalizationWorkload.hpp.

Constructor & Destructor Documentation

◆ NeonBatchNormalizationWorkload()

Definition at line 59 of file NeonBatchNormalizationWorkload.cpp.

61  : NeonBaseWorkload<BatchNormalizationQueueDescriptor>(descriptor, info)
62 {
63  // Report Profiling Details
64  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonBatchNormalizationWorkload_Construct",
65  descriptor.m_Parameters,
66  info,
67  this->GetGuid());
68 
69  m_Data.ValidateInputsOutputs("NeonBatchNormalizationWorkload", 1, 1);
70 
71  arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
72  arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
73 
74  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
75  input.info()->set_data_layout(aclDataLayout);
76  output.info()->set_data_layout(aclDataLayout);
77 
78  m_Mean = std::make_unique<arm_compute::Tensor>();
79  BuildArmComputeTensor(*m_Mean, m_Data.m_Mean->GetTensorInfo());
80 
81  m_Variance = std::make_unique<arm_compute::Tensor>();
82  BuildArmComputeTensor(*m_Variance, m_Data.m_Variance->GetTensorInfo());
83 
84  m_Gamma = std::make_unique<arm_compute::Tensor>();
85  BuildArmComputeTensor(*m_Gamma, m_Data.m_Gamma->GetTensorInfo());
86 
87  m_Beta = std::make_unique<arm_compute::Tensor>();
88  BuildArmComputeTensor(*m_Beta, m_Data.m_Beta->GetTensorInfo());
89 
90  const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor);
91 
92  auto layer = std::make_unique<arm_compute::NEBatchNormalizationLayer>();
93  layer->configure(&input,
94  &output,
95  m_Mean.get(),
96  m_Variance.get(),
97  m_Beta.get(),
98  m_Gamma.get(),
100  activationInfo);
101  m_Layer.reset(layer.release());
102 
107 
108  // Force Compute Library to perform the necessary copying and reshaping, after which
109  // delete all the input tensors that will no longer be needed
110  m_Layer->prepare();
111  FreeUnusedTensors();
112 }

References ARMNN_REPORT_PROFILING_WORKLOAD_DESC, armnn::info, BaseWorkload< BatchNormalizationQueueDescriptor >::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 114 of file NeonBatchNormalizationWorkload.cpp.

115 {
116  ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID("NeonBatchNormalizationWorkload_Execute");
117  m_Layer->run();
118 }

References ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID.


The documentation for this class was generated from the following files:
armnn::BatchNormalizationDescriptor::m_DataLayout
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Definition: Descriptors.hpp:843
armnn::BatchNormalizationQueueDescriptor::m_Gamma
const ConstTensorHandle * m_Gamma
Definition: WorkloadData.hpp:324
armnn::DataLayout
DataLayout
Definition: Types.hpp:62
armnn::QueueDescriptor::ValidateInputsOutputs
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Definition: WorkloadData.cpp:446
armnn::ConvertAdditionalInfoToAclActivationLayerInfo
arm_compute::ActivationLayerInfo ConvertAdditionalInfoToAclActivationLayerInfo(const QueueDescriptor &queueDescriptor)
Definition: ArmComputeUtils.hpp:105
armnn::BatchNormalizationQueueDescriptor::m_Variance
const ConstTensorHandle * m_Variance
Definition: WorkloadData.hpp:322
armnn::BatchNormalizationQueueDescriptor::m_Mean
const ConstTensorHandle * m_Mean
Definition: WorkloadData.hpp:321
armnn::ConstTensorHandle::GetTensorInfo
const TensorInfo & GetTensorInfo() const
Definition: TensorHandle.hpp:40
armnn::InitializeArmComputeTensorData
void InitializeArmComputeTensorData(arm_compute::Tensor &tensor, TensorInfo tensorInfo, const ITensorHandle *handle)
Definition: NeonWorkloadUtils.hpp:68
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
armnn::BatchNormalizationQueueDescriptor::m_Beta
const ConstTensorHandle * m_Beta
Definition: WorkloadData.hpp:323
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< BatchNormalizationQueueDescriptor >::m_Data
BatchNormalizationQueueDescriptor m_Data
Definition: Workload.hpp:89
ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
Definition: NeonWorkloadUtils.hpp:32
armnn::BatchNormalizationDescriptor::m_Eps
float m_Eps
Value to add to the variance. Used to avoid dividing by zero.
Definition: Descriptors.hpp:841
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26