Compute Library
 19.08
CLNormalizationLayer Class Reference

Basic function to compute a normalization layer. More...

#include <CLNormalizationLayer.h>

Collaboration diagram for CLNormalizationLayer:
[legend]

Public Member Functions

 CLNormalizationLayer ()
 Default constructor. More...
 
void configure (ICLTensor *input, ICLTensor *output, const NormalizationLayerInfo &norm_info)
 Set the input and output tensors. 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 NormalizationLayerInfo &norm_info)
 Static function to check if given info will lead to a valid configuration of CLNormalizationLayer. More...
 

Detailed Description

Basic function to compute a normalization layer.

This function calls the following CL kernels:

  1. CLFillBorderKernel
  2. CLNormalizationLayerKernel

Definition at line 46 of file CLNormalizationLayer.h.

Constructor & Destructor Documentation

◆ CLNormalizationLayer()

Default constructor.

Definition at line 35 of file CLNormalizationLayer.cpp.

36  : _norm_kernel(), _border_handler()
37 {
38 }

Member Function Documentation

◆ configure()

void configure ( ICLTensor input,
ICLTensor output,
const NormalizationLayerInfo norm_info 
)

Set the input and output tensors.

Parameters
[in,out]inputSource tensor. 3 lower dims represent a single input with dimensions [width, height, IFM], and an optional 4th dimension for batch of inputs. Data types supported: F16/F32 (Written to by the border handler). Data layouts supported: NCHW/NHWC.
[out]outputDestination tensor. Dimensions, data type and number of channels must match the input ones. Data types supported: same as input. Data layouts supported: same as input.
[in]norm_infoNormalization layer information like the normalization type, normalization size and other parameters.

Definition at line 40 of file CLNormalizationLayer.cpp.

41 {
42  ARM_COMPUTE_ERROR_ON(input == nullptr);
43 
44  // Configure normalization kernel
45  _norm_kernel.configure(input, output, norm_info);
46 
47  // Fill the border by 3 elements since we need vload4 in the IN_MAP normalization kernel
48  _border_handler.configure(input, _norm_kernel.border_size(), BorderMode::CONSTANT, PixelValue());
49 }
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:34
BorderSize border_size() const override
The size of the border for that kernel.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337
void configure(ICLTensor *tensor, BorderSize border_size, BorderMode border_mode, const PixelValue &constant_border_value=PixelValue())
Initialise the kernel's input, output and border mode.
void configure(const ICLTensor *input, ICLTensor *output, NormalizationLayerInfo norm_info)
Set the input and output tensors.

References ARM_COMPUTE_ERROR_ON, CLNormalizationLayerKernel::border_size(), CLNormalizationLayerKernel::configure(), CLFillBorderKernel::configure(), and arm_compute::CONSTANT.

◆ 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 56 of file CLNormalizationLayer.cpp.

57 {
58  // Run border handler
59  CLScheduler::get().enqueue(_border_handler, false);
60 
61  // Run normalization kernel
62  CLScheduler::get().enqueue(_norm_kernel);
63 }
static CLScheduler & get()
Access the scheduler singleton.
Definition: CLScheduler.cpp:41
void enqueue(ICLKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
Definition: CLScheduler.cpp:95

References CLScheduler::enqueue(), and CLScheduler::get().

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
const NormalizationLayerInfo norm_info 
)
static

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

Parameters
[in]inputSource tensor. 3 lower dims represent a single input with dimensions [width, height, IFM], and an optional 4th dimension for batch of inputs. Data types supported: F16/F32. Data layouts supported: NCHW/NHWC.
[in]outputDestination tensor. Dimensions, data type and number of channels must match the input ones. Data layouts supported: same as input.
[in]norm_infoNormalization layer information like the normalization type, normalization size and other parameters.
Returns
a status

Definition at line 51 of file CLNormalizationLayer.cpp.

52 {
53  return CLNormalizationLayerKernel::validate(input, output, norm_info);
54 }
static Status validate(const ITensorInfo *input, const ITensorInfo *output, NormalizationLayerInfo norm_info)
Static function to check if given info will lead to a valid configuration of CLNormalizationLayerKern...

References CLNormalizationLayerKernel::validate().


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