Compute Library
GCNormalizationLayer Class Reference

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

#include <GCNormalizationLayer.h>

Collaboration diagram for GCNormalizationLayer:

Public Member Functions

 GCNormalizationLayer (std::shared_ptr< IMemoryManager > memory_manager=nullptr)
 Default constructor. More...
void configure (const IGCTensor *input, IGCTensor *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...

Detailed Description

Basic function to compute a normalization layer.

This function calls the following OpenGL ES kernels:

  1. GCPixelWiseMultiplicationKernel
  2. GCFillBorderKernel
  3. GCNormalizationLayerKernel
This function is deprecated and is intended to be removed in 21.05 release

Definition at line 51 of file GCNormalizationLayer.h.

Constructor & Destructor Documentation

◆ GCNormalizationLayer()

GCNormalizationLayer ( std::shared_ptr< IMemoryManager memory_manager = nullptr)

Default constructor.

Definition at line 36 of file GCNormalizationLayer.cpp.

37  : _memory_group(std::move(memory_manager)), _squared_input(), _norm_kernel(), _multiply_kernel(), _border_handler()
38 {
39 }

Member Function Documentation

◆ configure()

void configure ( const IGCTensor input,
IGCTensor output,
const NormalizationLayerInfo norm_info 

Set the input and output tensors.

[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: F32. Number of channels must be 1.
[out]outputDestination tensor. Dimensions, data type and number of channels must match the input ones.
[in]norm_infoNormalization layer information like the normalization type, normalization size and other parameters.

Definition at line 41 of file GCNormalizationLayer.cpp.

References ITensorAllocator::allocate(), GCTensor::allocator(), ARM_COMPUTE_ERROR_ON, GCNormalizationLayerKernel::border_size(), GCPixelWiseMultiplicationKernel::configure(), GCNormalizationLayerKernel::configure(), GCFillBorderKernel::configure(), arm_compute::CONSTANT, ITensorInfo::data_type(), ITensor::info(), ITensorAllocator::init(), MemoryGroup::manage(), and ITensorInfo::tensor_shape().

42 {
43  ARM_COMPUTE_ERROR_ON(input == nullptr);
45  _squared_input.allocator()->init(TensorInfo(input->info()->tensor_shape(), 1, input->info()->data_type()));
46  _memory_group.manage(&_squared_input);
48  _norm_kernel.configure(input, &_squared_input, output, norm_info);
49  _multiply_kernel.configure(input, input, &_squared_input, 1.0f);
50  // Fill the border by 3 elements since we need vload4 in the IN_MAP normalization kernel
51  _border_handler.configure(&_squared_input, _norm_kernel.border_size(), BorderMode::CONSTANT, PixelValue());
53  // Allocate intermediate buffers
54  _squared_input.allocator()->allocate();
55 }
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:34
virtual DataType data_type() const =0
Data type used for each element of the tensor.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
void configure(const IGCTensor *input1, const IGCTensor *input2, IGCTensor *output, float scale)
Initialise the kernel&#39;s input, output and border mode.
void init(const TensorInfo &input, size_t alignment=0)
Initialize a tensor based on the passed TensorInfo.
void manage(IMemoryManageable *obj) override
Sets a object to be managed by the given memory group.
Definition: MemoryGroup.h:79
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
void configure(const IGCTensor *tensor, BorderSize border_size, BorderMode border_mode, const PixelValue &constant_border_value=PixelValue())
Initialise the kernel&#39;s input, output and border mode.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
void configure(const IGCTensor *input, const IGCTensor *squared_input, IGCTensor *output, NormalizationLayerInfo norm_info)
Set the input and output tensors.
virtual void allocate()=0
Interface to be implemented by the child class to allocate the tensor.
BorderSize border_size() const override
The size of the border for that kernel.
Store the tensor&#39;s metadata.
Definition: TensorInfo.h:45
ITensorAllocator * allocator()
Return a pointer to the tensor&#39;s allocator.
Definition: GCTensor.cpp:34

◆ run()

void run ( )

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.
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.
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 57 of file GCNormalizationLayer.cpp.

References GCScheduler::dispatch(), GCScheduler::get(), and GCScheduler::memory_barrier().

58 {
59  MemoryGroupResourceScope scope_mg(_memory_group);
61  GCScheduler::get().dispatch(_multiply_kernel, false);
63  GCScheduler::get().dispatch(_border_handler, false);
65  GCScheduler::get().dispatch(_norm_kernel, true);
66 }
void dispatch(IGCKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
Definition: GCScheduler.cpp:77
void memory_barrier()
Defines a barrier ordering memory transactions.
Definition: GCScheduler.cpp:86
static GCScheduler & get()
Access the scheduler singleton.
Definition: GCScheduler.cpp:70
Memory group resources scope handling class.
Definition: IMemoryGroup.h:82

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