ArmNN
 24.08
ClConstantWorkload Class Reference

#include <ClConstantWorkload.hpp>

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

Public Member Functions

 ClConstantWorkload (const ConstantQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
 
void Execute () const override
 
- Public Member Functions inherited from ClBaseWorkload< ConstantQueueDescriptor >
 ClBaseWorkload (const ConstantQueueDescriptor &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< ConstantQueueDescriptor >
 BaseWorkload (const ConstantQueueDescriptor &descriptor, const WorkloadInfo &info)
 
virtual const std::string & GetName () const override
 
void ExecuteAsync (ExecutionData &executionData) override
 
void PostAllocationConfigure () override
 
const ConstantQueueDescriptorGetData () 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< ConstantQueueDescriptor >
virtual void Reconfigure ()
 
- Protected Attributes inherited from BaseWorkload< ConstantQueueDescriptor >
ConstantQueueDescriptor m_Data
 
const arm::pipe::ProfilingGuid m_Guid
 
const std::string m_Name
 

Detailed Description

Definition at line 17 of file ClConstantWorkload.hpp.

Constructor & Destructor Documentation

◆ ClConstantWorkload()

ClConstantWorkload ( const ConstantQueueDescriptor descriptor,
const WorkloadInfo info,
const arm_compute::CLCompileContext &  clCompileContext 
)

Definition at line 44 of file ClConstantWorkload.cpp.

47  : ClBaseWorkload<ConstantQueueDescriptor>(descriptor, info)
48  , m_RanOnce(false)
49 {
50 }

References armnn::info.

Member Function Documentation

◆ Execute()

void Execute ( ) const
overridevirtual

Implements IWorkload.

Definition at line 52 of file ClConstantWorkload.cpp.

53 {
54  ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClConstantWorkload_Execute");
55 
56  // The intermediate tensor held by the corresponding layer output handler can be initialised with the given data
57  // on the first inference, then reused for subsequent inferences.
58  // The initialisation cannot happen at workload construction time since the ACL kernel for the next layer may not
59  // have been configured at the time.
60  if (!m_RanOnce)
61  {
62  const ConstantQueueDescriptor& data = this->m_Data;
63 
64  ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(data.m_LayerOutput, "Output tensor handle is null.");
65  arm_compute::CLTensor& output = static_cast<ClTensorHandle*>(data.m_Outputs[0])->GetTensor();
66  arm_compute::DataType computeDataType = static_cast<ClTensorHandle*>(data.m_Outputs[0])->GetDataType();
67 
68  switch (computeDataType)
69  {
70  case arm_compute::DataType::F16:
71  {
72  CopyArmComputeClTensorData(output, data.m_LayerOutput->GetConstTensor<Half>());
73  break;
74  }
75  case arm_compute::DataType::F32:
76  {
77  CopyArmComputeClTensorData(output, data.m_LayerOutput->GetConstTensor<float>());
78  break;
79  }
80  case arm_compute::DataType::QASYMM8:
81  {
82  CopyArmComputeClTensorData(output, data.m_LayerOutput->GetConstTensor<uint8_t>());
83  break;
84  }
85  case arm_compute::DataType::QASYMM8_SIGNED:
86  {
87  CopyArmComputeClTensorData(output, data.m_LayerOutput->GetConstTensor<int8_t>());
88  break;
89  }
90  case arm_compute::DataType::QSYMM16:
91  {
92  CopyArmComputeClTensorData(output, data.m_LayerOutput->GetConstTensor<int16_t>());
93  break;
94  }
95  case arm_compute::DataType::QSYMM8:
96  case arm_compute::DataType::QSYMM8_PER_CHANNEL:
97  {
98  CopyArmComputeClTensorData(output, data.m_LayerOutput->GetConstTensor<int8_t>());
99  break;
100  }
101  case arm_compute::DataType::S32:
102  {
103  CopyArmComputeClTensorData(output, data.m_LayerOutput->GetConstTensor<int32_t>());
104  break;
105  }
106  default:
107  {
108  throw InvalidArgumentException("Unknown data type.");
109  }
110  }
111 
112  m_RanOnce = true;
113  }
114 }

References ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID, ARMNN_THROW_INVALIDARG_MSG_IF_FALSE, armnn::CopyArmComputeClTensorData(), ConstTensorHandle::GetConstTensor(), BaseWorkload< ConstantQueueDescriptor >::m_Data, ConstantQueueDescriptor::m_LayerOutput, and QueueDescriptor::m_Outputs.


The documentation for this class was generated from the following files:
armnn::Half
half_float::half Half
Definition: Half.hpp:22
armnn::CopyArmComputeClTensorData
void CopyArmComputeClTensorData(arm_compute::CLTensor &dstTensor, const T *srcData)
Definition: ClWorkloadUtils.hpp:64
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::DataType
DataType
Definition: Types.hpp:48
armnn::BaseWorkload< ConstantQueueDescriptor >::m_Data
ConstantQueueDescriptor m_Data
Definition: Workload.hpp:89
ARMNN_THROW_INVALIDARG_MSG_IF_FALSE
#define ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(_cond, _str)
Definition: Exceptions.hpp:210