Compute Library
 21.02
NEActivationLayer Class Reference

Basic function to run cpu::kernels::CpuActivationKernel. More...

#include <NEActivationLayer.h>

Collaboration diagram for NEActivationLayer:
[legend]

Public Member Functions

 NEActivationLayer (IRuntimeContext *ctx=nullptr)
 Constructor. More...
 
 NEActivationLayer (const NEActivationLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEActivationLayer (NEActivationLayer &&)
 Default move constructor. More...
 
NEActivationLayeroperator= (const NEActivationLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEActivationLayeroperator= (NEActivationLayer &&)
 Default move assignment operator. More...
 
 ~NEActivationLayer ()
 Destructor. More...
 
void configure (ITensor *input, ITensor *output, ActivationLayerInfo activation_info)
 [NEActivationLayer snippet] 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)
 [NEActivationLayer snippet] More...
 

Detailed Description

Basic function to run cpu::kernels::CpuActivationKernel.

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

Definition at line 44 of file NEActivationLayer.h.

Constructor & Destructor Documentation

◆ NEActivationLayer() [1/3]

NEActivationLayer ( IRuntimeContext ctx = nullptr)

Constructor.

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

Definition at line 39 of file NEActivationLayer.cpp.

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

40  : _impl(std::make_unique<Impl>())
41 {
42  _impl->ctx = ctx;
43 }

◆ NEActivationLayer() [2/3]

NEActivationLayer ( const NEActivationLayer )
delete

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

◆ NEActivationLayer() [3/3]

Default move constructor.

◆ ~NEActivationLayer()

~NEActivationLayer ( )
default

Destructor.

Referenced by NEActivationLayer::NEActivationLayer().

Member Function Documentation

◆ configure()

void configure ( ITensor input,
ITensor output,
ActivationLayerInfo  activation_info 
)

[NEActivationLayer snippet]

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]activation_infoActivation layer parameters.

Definition at line 48 of file NEActivationLayer.cpp.

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

Referenced by NERNNLayer::configure(), NEGEMMConv2d::configure(), NEWinogradConvolutionLayer::configure(), NEDirectConvolutionLayer::configure(), NEFFTConvolutionLayer::configure(), NEGEMM::configure(), NEGEMMLowpMatrixMultiplyCore::configure(), NELSTMLayer::configure(), NELSTMLayerQuantized::configure(), NEQLSTMLayer::configure(), and arm_compute::test::validation::TEST_CASE().

49 {
50  _impl->src = input;
51  _impl->dst = output == nullptr ? input : output;
52 
53  ARM_COMPUTE_ERROR_ON_NULLPTR(_impl->src, _impl->dst);
54 
55  _impl->op = std::make_unique<cpu::CpuActivation>();
56  _impl->op->configure(_impl->src->info(), _impl->dst->info(), activation_info);
57 }
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

◆ operator=() [1/2]

NEActivationLayer& operator= ( const NEActivationLayer )
delete

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

Referenced by NEActivationLayer::NEActivationLayer().

◆ operator=() [2/2]

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

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

Referenced by NERNNLayer::run(), NEWinogradConvolutionLayer::run(), NEGEMMConv2d::run(), NEDirectConvolutionLayer::run(), NEGEMM::run(), NEFFTConvolutionLayer::run(), NEGEMMLowpMatrixMultiplyCore::run(), NELSTMLayerQuantized::run(), NELSTMLayer::run(), NEQLSTMLayer::run(), and arm_compute::test::validation::TEST_CASE().

65 {
66  ITensorPack pack;
67  pack.add_tensor(TensorType::ACL_SRC, _impl->src);
68  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
69  _impl->op->run(pack);
70 }

◆ validate()

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

[NEActivationLayer snippet]

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

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 59 of file NEActivationLayer.cpp.

References CpuActivation::validate().

Referenced by arm_compute::test::validation::DATA_TEST_CASE(), NERNNLayer::validate(), NEDirectConvolutionLayer::validate(), NEGEMM::validate(), NEFFTConvolutionLayer::validate(), NEGEMMLowpMatrixMultiplyCore::validate(), NELSTMLayerQuantized::validate(), NELSTMLayer::validate(), and NEQLSTMLayer::validate().

60 {
61  return cpu::CpuActivation::validate(input, output, act_info);
62 }
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 CpuActivation.

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