Compute Library
 21.11
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 39 of file CLPReluLayer.h.

Constructor & Destructor Documentation

◆ CLPReluLayer() [1/3]

Default Constructor.

Definition at line 42 of file CLPReluLayer.cpp.

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

43  : _impl(std::make_unique<Impl>())
44 {
45 }

◆ ~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.

Valid data layouts:

  • All

Valid data type configurations:

src dst
QASYMM8 QASYMM8
QASYMM8_SIGNED QASYMM8_SIGNED
F16 F16
F32 F32
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 50 of file CLPReluLayer.cpp.

References CLKernelLibrary::get().

Referenced by arm_compute::test::validation::compute_float_target_in_place().

51 {
52  configure(CLKernelLibrary::get().get_compile_context(), input, alpha, output);
53 }
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 55 of file CLPReluLayer.cpp.

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

56 {
57  _impl->src_0 = input;
58  _impl->src_1 = alpha;
59  _impl->dst = output;
60  _impl->op = std::make_unique<OperatorType>();
61  _impl->op->configure(compile_context, input->info(), alpha->info(), (output == nullptr ? input->info() : output->info()));
62 }

◆ 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 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 69 of file CLPReluLayer.cpp.

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

70 {
71  ITensorPack pack;
72  pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
73  pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
74  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
75 
76  _impl->op->run(pack);
77 }
void add_tensor(int id, ITensor *tensor)
Add tensor to the pack.
Definition: ITensorPack.cpp:39

◆ 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 64 of file CLPReluLayer.cpp.

References ClGemm::validate().

Referenced by arm_compute::test::validation::TEST_CASE().

65 {
66  return OperatorType::validate(input, alpha, output);
67 }
static Status validate(const ITensorInfo *a, const ITensorInfo *b, const ITensorInfo *c, const ITensorInfo *output, float alpha, float beta, const GEMMInfo &gemm_info)
Static function to check if given info will lead to a valid configuration.
Definition: ClGemm.cpp:517

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