ArmNN
 21.02
RefElementwiseUnaryWorkload Class Reference

#include <RefElementwiseUnaryWorkload.hpp>

Inheritance diagram for RefElementwiseUnaryWorkload:
BaseWorkload< ElementwiseUnaryQueueDescriptor > IWorkload

Public Member Functions

 RefElementwiseUnaryWorkload (const ElementwiseUnaryQueueDescriptor &descriptor, const WorkloadInfo &info)
 
void PostAllocationConfigure () override
 
void Execute () const override
 
- Public Member Functions inherited from BaseWorkload< ElementwiseUnaryQueueDescriptor >
 BaseWorkload (const ElementwiseUnaryQueueDescriptor &descriptor, const WorkloadInfo &info)
 
void PostAllocationConfigure () override
 
const ElementwiseUnaryQueueDescriptorGetData () const
 
profiling::ProfilingGuid GetGuid () const final
 
- Public Member Functions inherited from IWorkload
virtual ~IWorkload ()
 
virtual void RegisterDebugCallback (const DebugCallbackFunction &)
 

Additional Inherited Members

- Protected Attributes inherited from BaseWorkload< ElementwiseUnaryQueueDescriptor >
const ElementwiseUnaryQueueDescriptor m_Data
 
const profiling::ProfilingGuid m_Guid
 

Detailed Description

Definition at line 16 of file RefElementwiseUnaryWorkload.hpp.

Constructor & Destructor Documentation

◆ RefElementwiseUnaryWorkload()

RefElementwiseUnaryWorkload ( const ElementwiseUnaryQueueDescriptor descriptor,
const WorkloadInfo info 
)

Definition at line 26 of file RefElementwiseUnaryWorkload.cpp.

28  : BaseWorkload<ElementwiseUnaryQueueDescriptor>(desc, info)
29 {}

Member Function Documentation

◆ Execute()

void Execute ( ) const
overridevirtual

Implements IWorkload.

Definition at line 41 of file RefElementwiseUnaryWorkload.cpp.

References armnn::Abs, ARMNN_SCOPED_PROFILING_EVENT, CHECK_LOCATION, armnn::CpuRef, armnn::Exp, TensorInfo::GetShape(), armnn::GetTensorInfo(), armnn::GetUnaryOperationAsCString(), BaseWorkload< ElementwiseUnaryQueueDescriptor >::m_Data, QueueDescriptor::m_Inputs, ElementwiseUnaryDescriptor::m_Operation, QueueDescriptor::m_Outputs, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, armnn::Neg, armnn::Rsqrt, and armnn::Sqrt.

42 {
43  ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefElementwiseUnaryWorkload_Execute");
44 
45  const TensorInfo& inputInfo = GetTensorInfo(m_Data.m_Inputs[0]);
46  const TensorInfo& outputInfo = GetTensorInfo(m_Data.m_Outputs[0]);
47 
48  const TensorShape& inShape = inputInfo.GetShape();
49  const TensorShape& outShape = outputInfo.GetShape();
50 
51  m_Input->Reset(m_Data.m_Inputs[0]->Map());
52  m_Output->Reset(m_Data.m_Outputs[0]->Map());
53 
54  using AbsFunction = ElementwiseUnaryFunction<abs<InType>>;
55  using ExpFunction = ElementwiseUnaryFunction<exp<InType>>;
56  using NegFunction = ElementwiseUnaryFunction<std::negate<InType>>;
57  using RsqrtFunction = ElementwiseUnaryFunction<rsqrt<InType>>;
58  using SqrtFunction = ElementwiseUnaryFunction<sqrt<InType>>;
59 
61  {
63  {
64  AbsFunction(inShape, outShape, *m_Input, *m_Output);
65  break;
66  }
68  {
69  ExpFunction(inShape, outShape, *m_Input, *m_Output);
70  break;
71  }
73  {
74  NegFunction(inShape, outShape, *m_Input, *m_Output);
75  break;
76  }
78  {
79  RsqrtFunction(inShape, outShape, *m_Input, *m_Output);
80  break;
81  }
83  {
84  SqrtFunction(inShape, outShape, *m_Input, *m_Output);
85  break;
86  }
87  default:
88  {
89  throw InvalidArgumentException(std::string("Unsupported unary operation ") +
91  }
92  }
93 }
UnaryOperation m_Operation
Specifies the elementwiseUnary operation to execute.
CPU Execution: Reference C++ kernels.
const ElementwiseUnaryQueueDescriptor m_Data
Definition: Workload.hpp:46
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:173
constexpr char const * GetUnaryOperationAsCString(UnaryOperation operation)
Definition: TypesUtils.hpp:71
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197
std::vector< ITensorHandle * > m_Outputs
std::vector< ITensorHandle * > m_Inputs
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers

◆ PostAllocationConfigure()

void PostAllocationConfigure ( )
overridevirtual

Implements IWorkload.

Definition at line 31 of file RefElementwiseUnaryWorkload.cpp.

References armnn::GetTensorInfo(), BaseWorkload< ElementwiseUnaryQueueDescriptor >::m_Data, QueueDescriptor::m_Inputs, and QueueDescriptor::m_Outputs.

32 {
33  const TensorInfo& inputInfo = GetTensorInfo(m_Data.m_Inputs[0]);
34  const TensorInfo& outputInfo = GetTensorInfo(m_Data.m_Outputs[0]);
35 
36  m_Input = MakeDecoder<InType>(inputInfo);
37 
38  m_Output = MakeEncoder<OutType>(outputInfo);
39 }
const ElementwiseUnaryQueueDescriptor m_Data
Definition: Workload.hpp:46
std::vector< ITensorHandle * > m_Outputs
std::vector< ITensorHandle * > m_Inputs
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers

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