Compute Library
 20.11
NEActivationLayer Class Reference

Basic function to run NEActivationLayerKernel. 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 NEActivationLayerKernel.

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

Definition at line 41 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 60 of file NEActivationLayer.cpp.

61  : _impl(support::cpp14::make_unique<Impl>())
62 {
63  _impl->ctx = ctx;
64 }

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

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

73 {
75 
76  _impl->src = input;
77  _impl->dst = output == nullptr ? input : output;
78 
79  _impl->op = arm_compute::support::cpp14::make_unique<experimental::NEActivationLayer>();
80  _impl->op->configure(_impl->src->info(), _impl->dst->info(), activation_info);
81 }
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

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().

◆ operator=() [1/2]

NEActivationLayer& operator= ( const NEActivationLayer )
delete

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

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

89 {
90  ITensorPack pack;
91  pack.add_tensor(TensorType::ACL_SRC, _impl->src);
92  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
93  _impl->op->run(pack);
94 }

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

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

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

84 {
85  return experimental::NEActivationLayer::validate(input, output, act_info);
86 }
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 NEActivationLayer.

References arm_compute::test::validation::input, and NEActivationLayer::validate().

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


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