Compute Library
 21.02
CLActivationLayer Class Reference

Basic function to run opencl::kernels::ClActivationKernel. More...

#include <CLActivationLayer.h>

Collaboration diagram for CLActivationLayer:
[legend]

Public Member Functions

 CLActivationLayer (CLRuntimeContext *ctx=nullptr)
 Constructor. More...
 
 ~CLActivationLayer ()
 Destructor. More...
 
 CLActivationLayer (const CLActivationLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLActivationLayer (CLActivationLayer &&)
 Default move constructor. More...
 
CLActivationLayeroperator= (const CLActivationLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLActivationLayeroperator= (CLActivationLayer &&)
 Default move assignment operator. More...
 
void configure (ICLTensor *input, ICLTensor *output, ActivationLayerInfo act_info)
 Set the input and output tensor. More...
 
void configure (const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, ActivationLayerInfo act_info)
 Set the input and output tensor. 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 *input, const ITensorInfo *output, const ActivationLayerInfo &act_info)
 Static function to check if given info will lead to a valid configuration of CLActivationLayer. More...
 

Detailed Description

Basic function to run opencl::kernels::ClActivationKernel.

Note
The function simulates an activation layer with the specified activation function.

Definition at line 42 of file CLActivationLayer.h.

Constructor & Destructor Documentation

◆ CLActivationLayer() [1/3]

CLActivationLayer ( CLRuntimeContext ctx = nullptr)

Constructor.

Parameters
[in]ctxRuntime context to be used by the function

Definition at line 43 of file CLActivationLayer.cpp.

References CLActivationLayer::operator=(), and CLActivationLayer::~CLActivationLayer().

44  : _impl(std::make_unique<Impl>())
45 {
46  _impl->ctx = ctx;
47 }

◆ ~CLActivationLayer()

~CLActivationLayer ( )
default

Destructor.

Referenced by CLActivationLayer::CLActivationLayer().

◆ CLActivationLayer() [2/3]

CLActivationLayer ( const CLActivationLayer )
delete

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

◆ CLActivationLayer() [3/3]

Default move constructor.

Member Function Documentation

◆ configure() [1/2]

void configure ( ICLTensor input,
ICLTensor output,
ActivationLayerInfo  act_info 
)

Set the input and output tensor.

Note
If the output tensor is a nullptr or is equal to the input, the activation function will be performed in-place
Parameters
[in,out]inputSource tensor. In case of output tensor = nullptr, this tensor will store the result of the activation function. Data types supported: QASYMM8/QASYMM8_SIGNED/QSYMM16/F16/F32.
[out]outputDestination tensor. Data type supported: same as input
[in]act_infoActivation layer parameters.

Definition at line 52 of file CLActivationLayer.cpp.

References CLKernelLibrary::get().

Referenced by CLRNNLayer::configure(), CLDirectConvolutionLayer::configure(), CLFFTConvolutionLayer::configure(), CLLSTMLayerQuantized::configure(), CLLSTMLayer::configure(), CLQLSTMLayer::configure(), CLGEMMConvolutionLayer::configure(), and arm_compute::test::validation::TEST_CASE().

53 {
54  configure(CLKernelLibrary::get().get_compile_context(), input, output, act_info);
55 }
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
void configure(ICLTensor *input, ICLTensor *output, ActivationLayerInfo act_info)
Set the input and output tensor.

◆ configure() [2/2]

void configure ( const CLCompileContext compile_context,
ICLTensor input,
ICLTensor output,
ActivationLayerInfo  act_info 
)

Set the input and output tensor.

Note
If the output tensor is a nullptr or is equal to the input, the activation function will be performed in-place
Parameters
[in]compile_contextThe compile context to be used.
[in,out]inputSource tensor. In case of output tensor = nullptr, this tensor will store the result of the activation function. Data types supported: QASYMM8/QASYMM8_SIGNED/QSYMM16/F16/F32.
[out]outputDestination tensor. Data type supported: same as input
[in]act_infoActivation layer parameters.

Definition at line 57 of file CLActivationLayer.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, and arm_compute::test::validation::input.

58 {
60 
61  _impl->src = input;
62  _impl->dst = output == nullptr ? input : output;
63 
64  _impl->op = std::make_unique<opencl::ClActivation>();
65  _impl->op->configure(compile_context, _impl->src->info(), _impl->dst->info(), act_info);
66 }
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

◆ operator=() [1/2]

CLActivationLayer& operator= ( const CLActivationLayer )
delete

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

Referenced by CLActivationLayer::CLActivationLayer().

◆ operator=() [2/2]

CLActivationLayer & operator= ( CLActivationLayer &&  )
default

Default move assignment operator.

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For Neon 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 73 of file CLActivationLayer.cpp.

References arm_compute::ACL_DST, arm_compute::ACL_SRC, and ITensorPack::add_tensor().

Referenced by CLRNNLayer::run(), CLDirectConvolutionLayer::run(), CLFFTConvolutionLayer::run(), CLLSTMLayerQuantized::run(), CLLSTMLayer::run(), CLQLSTMLayer::run(), CLGEMMConvolutionLayer::run(), and arm_compute::test::validation::TEST_CASE().

74 {
75  ITensorPack pack;
76  pack.add_tensor(TensorType::ACL_SRC, _impl->src);
77  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
78  _impl->op->run(pack);
79 }

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
const ActivationLayerInfo act_info 
)
static

Static function to check if given info will lead to a valid configuration of CLActivationLayer.

Parameters
[in]inputSource tensor info. In case of output tensor info = nullptr, this tensor will store the result of the activation function. Data types supported: QASYMM8/QASYMM8_SIGNED/QSYMM16/F16/F32.
[in]outputDestination tensor info. Data type supported: same as input
[in]act_infoActivation layer information.
Returns
a status

Definition at line 68 of file CLActivationLayer.cpp.

References ClActivation::validate().

Referenced by arm_compute::test::validation::DATA_TEST_CASE(), CLRNNLayer::validate(), CLDirectConvolutionLayer::validate(), CLFFTConvolutionLayer::validate(), CLLSTMLayerQuantized::validate(), CLLSTMLayer::validate(), CLQLSTMLayer::validate(), and CLGEMMConvolutionLayer::validate().

69 {
70  return opencl::ClActivation::validate(input, output, act_info);
71 }
static Status validate(const ITensorInfo *src, const ITensorInfo *dst, const ActivationLayerInfo &act_info)
Static function to check if given info will lead to a valid configuration of ClActivation.

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