Compute Library
 23.11
CLArithmeticAddition Class Reference

Basic function to run opencl::kernels::ClSaturatedArithmeticKernel for addition. More...

#include <CLElementwiseOperations.h>

Collaboration diagram for CLArithmeticAddition:
[legend]

Public Member Functions

 CLArithmeticAddition ()
 Default Constructor. More...
 
 ~CLArithmeticAddition ()
 Default Destructor. More...
 
 CLArithmeticAddition (const CLArithmeticAddition &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLArithmeticAddition (CLArithmeticAddition &&)
 Default move constructor. More...
 
CLArithmeticAdditionoperator= (const CLArithmeticAddition &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLArithmeticAdditionoperator= (CLArithmeticAddition &&)
 Default move assignment operator. More...
 
void configure (ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
 Initialise the kernel's inputs, output and conversion policy. More...
 
void configure (const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
 Initialise the kernel's inputs, output and conversion policy. More...
 
void run () override
 Run the kernels contained in the function. More...
 
- Public Member Functions inherited from IFunction
virtual ~IFunction ()=default
 Destructor. More...
 
virtual void prepare ()
 Prepare the function for executing. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
 Static function to check if given info will lead to a valid configuration of opencl::kernels::ClSaturatedArithmeticKernel for addition. More...
 

Detailed Description

Basic function to run opencl::kernels::ClSaturatedArithmeticKernel for addition.

Note
The tensor data type for the inputs must be U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
The function performs an arithmetic addition between two tensors.

Definition at line 42 of file CLElementwiseOperations.h.

Constructor & Destructor Documentation

◆ CLArithmeticAddition() [1/3]

Default Constructor.

Definition at line 45 of file CLElementwiseOperations.cpp.

45  : _impl(std::make_unique<Impl>())
46 {
47 }

◆ ~CLArithmeticAddition()

~CLArithmeticAddition ( )
default

Default Destructor.

◆ CLArithmeticAddition() [2/3]

Prevent instances of this class from being copied (As this class contains pointers)

◆ CLArithmeticAddition() [3/3]

Default move constructor.

Member Function Documentation

◆ configure() [1/2]

void configure ( const CLCompileContext compile_context,
const ICLTensor input1,
const ICLTensor input2,
ICLTensor output,
ConvertPolicy  policy,
const ActivationLayerInfo act_info = ActivationLayerInfo() 
)

Initialise the kernel's inputs, output and conversion policy.

Valid configurations (Input1,Input2) -> Output :

  • (U8,U8) -> U8
  • (U8,U8) -> S16
  • (S16,U8) -> S16
  • (U8,S16) -> S16
  • (S16,S16) -> S16
  • (S32,S32) -> S32
  • (F16,F16) -> F16
  • (F32,F32) -> F32
  • (QASYMM8,QASYMM8) -> QASYMM8
  • (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED
  • (QSYMM16,QSYMM16) -> QSYMM16
Parameters
[in]compile_contextThe compile context to be used.
[in,out]input1First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
[in,out]input2Second tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
[out]outputOutput tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
[in]policyPolicy to use to handle overflow.
[in]act_info(Optional) Activation layer information in case of a fused activation.

Definition at line 58 of file CLElementwiseOperations.cpp.

64 {
65  _impl->src_0 = input1;
66  _impl->src_1 = input2;
67  _impl->dst = output;
68  _impl->op = std::make_unique<opencl::ClAdd>();
69  _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), policy, act_info);
70 }

References arm_compute::test::validation::act_info, and ITensor::info().

◆ configure() [2/2]

void configure ( ICLTensor input1,
ICLTensor input2,
ICLTensor output,
ConvertPolicy  policy,
const ActivationLayerInfo act_info = ActivationLayerInfo() 
)

Initialise the kernel's inputs, output and conversion policy.

Valid data layouts:

  • All

Valid data type configurations:

src0 src1 dst
QASYMM8 QASYMM8 QASYMM8
QASYMM8_SIGNED QASYMM8_SIGNED QASYMM8_SIGNED
QSYMM16 QSYMM16 QASYMM16
U8 U8 U8
U8 U8 S16
U8 S16 S16
S16 U8 S16
S16 S16 S16
S32 S32 S32
F16 F16 F16
F32 F32 F32
Parameters
[in,out]input1First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
[in,out]input2Second tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
[out]outputOutput tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
[in]policyPolicy to use to handle overflow.
[in]act_info(Optional) Activation layer information in case of a fused activation.

Definition at line 52 of file CLElementwiseOperations.cpp.

54 {
55  configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, policy, act_info);
56 }

References arm_compute::test::validation::act_info, and CLKernelLibrary::get().

Referenced by CLRNNLayer::configure(), CLFFTConvolutionLayer::configure(), CLLSTMLayerQuantized::configure(), CLLSTMLayer::configure(), and CLQLSTMLayer::configure().

◆ operator=() [1/2]

CLArithmeticAddition & operator= ( CLArithmeticAddition &&  )
default

Default move assignment operator.

◆ operator=() [2/2]

CLArithmeticAddition& operator= ( const CLArithmeticAddition )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For CPU kernels:

  • Multi-threading is used for the kernels which are parallelisable.
  • By default std::thread::hardware_concurrency() threads are used.
Note
CPPScheduler::set_num_threads() can be used to manually set the number of threads

For OpenCL kernels:

  • All the kernels are enqueued on the queue associated with CLScheduler.
  • The queue is then flushed.
Note
The function will not block until the kernels are executed. It is the user's responsibility to wait.
Will call prepare() on first run if hasn't been done

Implements IFunction.

Definition at line 81 of file CLElementwiseOperations.cpp.

82 {
83  ITensorPack pack;
84  pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
85  pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
86  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
87 
88  _impl->op->run(pack);
89 }

References arm_compute::ACL_DST, arm_compute::ACL_SRC_0, arm_compute::ACL_SRC_1, ITensorPack::add_tensor(), and arm_compute::test::validation::pack.

Referenced by CLQLSTMLayer::prepare(), CLRNNLayer::run(), CLFFTConvolutionLayer::run(), CLLSTMLayerQuantized::run(), CLLSTMLayer::run(), and CLQLSTMLayer::run().

◆ validate()

Status validate ( const ITensorInfo input1,
const ITensorInfo input2,
const ITensorInfo output,
ConvertPolicy  policy,
const ActivationLayerInfo act_info = ActivationLayerInfo() 
)
static

Static function to check if given info will lead to a valid configuration of opencl::kernels::ClSaturatedArithmeticKernel for addition.

Valid configurations (Input1,Input2) -> Output :

  • (U8,U8) -> U8
  • (U8,U8) -> S16
  • (S16,U8) -> S16
  • (U8,S16) -> S16
  • (S16,S16) -> S16
  • (S32,S32) -> S32
  • (F16,F16) -> F16
  • (F32,F32) -> F32
  • (QASYMM8,QASYMM8) -> QASYMM8
  • (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED
  • (QSYMM16,QSYMM16) -> QSYMM16
Parameters
[in]input1First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
[in]input2Second tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
[in]outputOutput tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
[in]policyPolicy to use to handle overflow.
[in]act_info(Optional) Activation layer information in case of a fused activation.
Returns
a status

Definition at line 72 of file CLElementwiseOperations.cpp.

77 {
78  return opencl::ClAdd::validate(input1, input2, output, policy, act_info);
79 }

References arm_compute::test::validation::act_info, and ClAdd::validate().

Referenced by arm_compute::test::validation::TEST_CASE(), CLRNNLayer::validate(), CLLSTMLayerQuantized::validate(), CLLSTMLayer::validate(), and CLQLSTMLayer::validate().


The documentation for this class was generated from the following files:
arm_compute::opencl::ClAdd::validate
static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, ConvertPolicy policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration.
Definition: ClAdd.cpp:47
arm_compute::ITensorPack::add_tensor
void add_tensor(int id, ITensor *tensor)
Add tensor to the pack.
Definition: ITensorPack.cpp:38
arm_compute::ACL_SRC_0
@ ACL_SRC_0
Definition: Types.h:45
arm_compute::ACL_SRC_1
@ ACL_SRC_1
Definition: Types.h:46
arm_compute::CLKernelLibrary::get
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
Definition: CLKernelLibrary.cpp:41
arm_compute::test::validation::act_info
act_info
Definition: DirectConvolutionLayer.cpp:547
arm_compute::ACL_DST
@ ACL_DST
Definition: Types.h:55
arm_compute::CLArithmeticAddition::configure
void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Initialise the kernel's inputs, output and conversion policy.
Definition: CLElementwiseOperations.cpp:52
arm_compute::test::validation::pack
ITensorPack pack
Definition: Im2Col.cpp:188