Compute Library
 21.02
CLPReluLayer Class Reference

Basic function to run opencl::kernels::ClArithmeticKernel for PRELU. More...

#include <CLPReluLayer.h>

Collaboration diagram for CLPReluLayer:
[legend]

Public Member Functions

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

Detailed Description

Basic function to run opencl::kernels::ClArithmeticKernel for PRELU.

Note
The function implements an activation layer with the PRELU activation function.

Definition at line 76 of file CLPReluLayer.h.

Constructor & Destructor Documentation

◆ CLPReluLayer() [1/3]

Default Constructor.

Definition at line 64 of file CLPReluLayer.cpp.

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

65  : _impl(std::make_unique<Impl>())
66 {
67 }

◆ ~CLPReluLayer()

~CLPReluLayer ( )
default

Default Destructor.

Referenced by CLPReluLayer::CLPReluLayer().

◆ CLPReluLayer() [2/3]

CLPReluLayer ( const CLPReluLayer )
delete

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

◆ CLPReluLayer() [3/3]

CLPReluLayer ( CLPReluLayer &&  )
default

Default move constructor.

Member Function Documentation

◆ configure() [1/2]

void configure ( ICLTensor input,
ICLTensor alpha,
ICLTensor output 
)

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]inputSource tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
[in]alphaPRelu layer parameters. Data types supported: same of input.
[out]outputDestination tensor. Data type supported: same as input

Definition at line 72 of file CLPReluLayer.cpp.

References CLKernelLibrary::get().

73 {
74  configure(CLKernelLibrary::get().get_compile_context(), input, alpha, output);
75 }
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
void configure(ICLTensor *input, ICLTensor *alpha, ICLTensor *output)
Set the input and output tensor.

◆ configure() [2/2]

void configure ( const CLCompileContext compile_context,
ICLTensor input,
ICLTensor alpha,
ICLTensor output 
)

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]inputSource tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
[in]alphaPRelu layer parameters. Data types supported: same of input.
[out]outputDestination tensor. Data type supported: same as input

Definition at line 77 of file CLPReluLayer.cpp.

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

78 {
79  _impl->src_0 = input;
80  _impl->src_1 = alpha;
81  _impl->dst = output;
82  _impl->op = std::make_unique<experimental::CLPReluLayer>();
83  _impl->op->configure(compile_context, input->info(), alpha->info(), output->info());
84 }

◆ operator=() [1/2]

CLPReluLayer& operator= ( const CLPReluLayer )
delete

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

Referenced by CLPReluLayer::CLPReluLayer().

◆ operator=() [2/2]

CLPReluLayer & operator= ( CLPReluLayer &&  )
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 91 of file CLPReluLayer.cpp.

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

92 {
93  ITensorPack pack;
94  pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
95  pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
96  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
97 
98  _impl->op->run(pack);
99 }

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo alpha,
const ITensorInfo output 
)
static

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

Parameters
[in]inputSource tensor info. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
[in]alphaPRelu layer parameters. Data types supported: same of input.
[in]outputDestination tensor info. Data type supported: same as input
Returns
a status

Definition at line 86 of file CLPReluLayer.cpp.

References CLPReluLayer::validate().

87 {
88  return experimental::CLPReluLayer::validate(input, alpha, output);
89 }
static Status validate(const ITensorInfo *input, const ITensorInfo *alpha, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of CLPReluLayer.

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