Compute Library
 22.02
ClPRelu Class Reference

Basic operator to run arm_compute::opencl::kernels::ClArithmeticKernel for PRELU. More...

#include <ClPRelu.h>

Collaboration diagram for ClPRelu:
[legend]

Public Member Functions

void configure (const CLCompileContext &compile_context, ITensorInfo *input, ITensorInfo *alpha, ITensorInfo *output)
 Set the input and output tensor. More...
 
void run (ITensorPack &tensors) override
 Run the kernels contained in the function. More...
 
- Public Member Functions inherited from ICLOperator
 ICLOperator (IRuntimeContext *ctx=nullptr)
 Constructor. More...
 
 ICLOperator (const ICLOperator &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 ICLOperator (ICLOperator &&)=default
 Default move constructor. More...
 
ICLOperatoroperator= (const ICLOperator &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
ICLOperatoroperator= (ICLOperator &&)=default
 Default move assignment operator. More...
 
void prepare (ITensorPack &constants) override
 Prepare the function for executing. More...
 
MemoryRequirements workspace () const override
 Return the memory requirements required by the workspace. More...
 
- Public Member Functions inherited from IOperator
virtual ~IOperator ()=default
 Destructor. 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. More...
 

Detailed Description

Basic operator to run arm_compute::opencl::kernels::ClArithmeticKernel for PRELU.

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

Definition at line 38 of file ClPRelu.h.

Member Function Documentation

◆ configure()

void configure ( const CLCompileContext compile_context,
ITensorInfo input,
ITensorInfo alpha,
ITensorInfo 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 35 of file ClPRelu.cpp.

References ARM_COMPUTE_LOG_PARAMS, arm_compute::test::validation::k, and arm_compute::PRELU.

36 {
37  ARM_COMPUTE_LOG_PARAMS(input, alpha, output);
38  auto k = std::make_unique<KernelType>();
39  k->configure(compile_context, ArithmeticOperation::PRELU, input, alpha, (output == nullptr ? input : output));
40  _kernel = std::move(k);
41 }
y*x if x < 0, x otherwise
#define ARM_COMPUTE_LOG_PARAMS(...)

◆ run()

void run ( ITensorPack tensors)
overridevirtual

Run the kernels contained in the function.

Parameters
[in]tensorsVector that contains the tensors to operate on.

Reimplemented from ICLOperator.

Definition at line 48 of file ClPRelu.cpp.

References arm_compute::ACL_DST, arm_compute::ACL_SRC_0, ITensorPack::add_tensor(), ARM_COMPUTE_ERROR_ON_MSG, ITensorPack::get_const_tensor(), ITensorPack::get_tensor(), and ICLOperator::run().

49 {
50  // Output tensor can be given as nullptr for in-place computation.
51  // In this case, get the input tensor and use it as the output tensor.
52  if(tensors.get_tensor(TensorType::ACL_DST) == nullptr)
53  {
54  auto src_tensor = const_cast<ITensor *>(tensors.get_const_tensor(TensorType::ACL_SRC_0));
55  ARM_COMPUTE_ERROR_ON_MSG(src_tensor == nullptr, "invalid source tensor is given for in-place computation");
56  tensors.add_tensor(TensorType::ACL_DST, src_tensor);
57  }
58  IClOperator::run(tensors);
59 }
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
void run(ITensorPack &tensors) override
Run the kernels contained in the function.
Definition: CLOperator.cpp:38

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

Similar to ClPRelu::configure()

Returns
a status

Definition at line 43 of file ClPRelu.cpp.

References arm_compute::PRELU, and ClArithmeticKernel::validate().

44 {
45  return KernelType::validate(ArithmeticOperation::PRELU, input, alpha, (output == nullptr ? input : output));
46 }
static Status validate(ArithmeticOperation op, const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration.
y*x if x < 0, x otherwise

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