ArmNN
 23.11
NeonNormalizationFloatWorkload Class Reference

#include <NeonNormalizationFloatWorkload.hpp>

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

Public Member Functions

 NeonNormalizationFloatWorkload (const NormalizationQueueDescriptor &descriptor, const WorkloadInfo &info, std::shared_ptr< arm_compute::MemoryManagerOnDemand > &memoryManager)
 
virtual void Execute () const override
 
void ReplaceInputTensorHandle (ITensorHandle *tensorHandle, unsigned int slot) override
 
void ReplaceOutputTensorHandle (ITensorHandle *tensorHandle, unsigned int slot) override
 
- Public Member Functions inherited from TypedWorkload< QueueDescriptor, DataTypes >
 TypedWorkload (const QueueDescriptor &descriptor, const WorkloadInfo &info)
 
- Public Member Functions inherited from BaseWorkload< QueueDescriptor >
 BaseWorkload (const QueueDescriptor &descriptor, const WorkloadInfo &info)
 
virtual const std::string & GetName () const override
 
void ExecuteAsync (ExecutionData &executionData) override
 
void PostAllocationConfigure () override
 
const QueueDescriptorGetData () 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 Attributes inherited from BaseWorkload< QueueDescriptor >
QueueDescriptor m_Data
 
const arm::pipe::ProfilingGuid m_Guid
 
const std::string m_Name
 

Detailed Description

Definition at line 23 of file NeonNormalizationFloatWorkload.hpp.

Constructor & Destructor Documentation

◆ NeonNormalizationFloatWorkload()

NeonNormalizationFloatWorkload ( const NormalizationQueueDescriptor descriptor,
const WorkloadInfo info,
std::shared_ptr< arm_compute::MemoryManagerOnDemand > &  memoryManager 
)

Definition at line 61 of file NeonNormalizationFloatWorkload.cpp.

64  : FloatWorkload<NormalizationQueueDescriptor>(descriptor, info)
65 {
66  // Report Profiling Details
67  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonNormalizationWorkload_Construct",
68  descriptor.m_Parameters,
69  info,
70  this->GetGuid());
71 
72  m_Data.ValidateInputsOutputs("NeonNormalizationFloatWorkload", 1, 1);
73  std::string reasonIfUnsupported;
74  if (!IsNeonNormalizationDescriptorSupported(m_Data.m_Parameters, Optional<std::string&>(reasonIfUnsupported)))
75  {
76  throw UnimplementedException(reasonIfUnsupported);
77  }
78 
79  // Input and output tensors have to have the same dimensionality.
80  if (info.m_InputTensorInfos[0].GetShape()[1] != info.m_OutputTensorInfos[0].GetShape()[1]
81  || info.m_InputTensorInfos[0].GetShape()[0] != info.m_OutputTensorInfos[0].GetShape()[0]
82  || info.m_InputTensorInfos[0].GetShape()[3] != info.m_OutputTensorInfos[0].GetShape()[3]
83  || info.m_InputTensorInfos[0].GetShape()[2] != info.m_OutputTensorInfos[0].GetShape()[2])
84  {
85  throw InvalidArgumentException("Normalization requires input and output tensors to have equal dimensionality.");
86  }
87 
88  arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
89  arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
90  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
91  input.info()->set_data_layout(aclDataLayout);
92  output.info()->set_data_layout(aclDataLayout);
93 
94  const arm_compute::NormType normType =
95  ConvertNormalizationAlgorithmChannelToAclNormType(m_Data.m_Parameters.m_NormChannelType);
96  arm_compute::NormalizationLayerInfo normalizationInfo(normType,
97  m_Data.m_Parameters.m_NormSize,
98  m_Data.m_Parameters.m_Alpha,
99  m_Data.m_Parameters.m_Beta,
100  m_Data.m_Parameters.m_K,
101  false);
102  auto layer = std::make_unique<arm_compute::NENormalizationLayer>(memoryManager);
103  layer->configure(&input, &output, normalizationInfo);
104  m_NormalizationLayer.reset(layer.release());
105 }

References ARMNN_REPORT_PROFILING_WORKLOAD_DESC, armnn::info, BaseWorkload< QueueDescriptor >::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 107 of file NeonNormalizationFloatWorkload.cpp.

108 {
109  ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID("NeonNormalizationFloatWorkload_Execute");
110  m_NormalizationLayer->run();
111 }

References ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID.

◆ ReplaceInputTensorHandle()

void ReplaceInputTensorHandle ( ITensorHandle tensorHandle,
unsigned int  slot 
)
overridevirtual

Reimplemented from BaseWorkload< QueueDescriptor >.

Definition at line 113 of file NeonNormalizationFloatWorkload.cpp.

114 {
115  ITensorHandle* backupHandle = this->m_Data.m_Inputs[slot];
116  this->m_Data.m_Inputs[slot] = tensorHandle;
117  try
118  {
119  Reconfigure();
120  }
122  {
123  // Cannot reconfigure, revert the slot back and throw the exception.
124  this->m_Data.m_Inputs[slot] = backupHandle;
125  throw e;
126  }
127 }

References BaseWorkload< QueueDescriptor >::m_Data, and QueueDescriptor::m_Inputs.

◆ ReplaceOutputTensorHandle()

void ReplaceOutputTensorHandle ( ITensorHandle tensorHandle,
unsigned int  slot 
)
overridevirtual

Reimplemented from BaseWorkload< QueueDescriptor >.

Definition at line 130 of file NeonNormalizationFloatWorkload.cpp.

131 {
132  ITensorHandle* backupHandle = this->m_Data.m_Inputs[slot];
133  this->m_Data.m_Inputs[slot] = tensorHandle;
134  try
135  {
136  Reconfigure();
137  }
139  {
140  // Cannot reconfigure, revert the slot back and throw the exception.
141  this->m_Data.m_Inputs[slot] = backupHandle;
142  throw e;
143  }
144 }

References BaseWorkload< QueueDescriptor >::m_Data, and QueueDescriptor::m_Inputs.


The documentation for this class was generated from the following files:
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::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::m_Data
QueueDescriptor m_Data
Definition: Workload.hpp:89
armnn::ConvertNormalizationAlgorithmChannelToAclNormType
arm_compute::NormType ConvertNormalizationAlgorithmChannelToAclNormType(NormalizationAlgorithmChannel channelType)
Definition: ArmComputeUtils.hpp:182
armnn::UnimplementedException
Definition: Exceptions.hpp:98
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::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26