clDNN
cldnn::normalize Struct Reference

Normalizes the input using an L2 norm and multiplies the output with scale value. The scale can be equal for all channels or one scale per channel. More...

#include <normalize.hpp>

Inheritance diagram for cldnn::normalize:
Collaboration diagram for cldnn::normalize:

Public Types

typedef cldnn_normalize_desc dto
 

Public Member Functions

 normalize (const primitive_id &id, const primitive_id &input, const primitive_id &scale_input, const bool across_spatial=true, const float epsilon=1e-10f, const padding &output_padding=padding())
 Constructs normalize primitive. More...
 
 normalize (const dto *dto)
 Constructs a copy from C API cldnn_normalize_desc.
 
- Public Member Functions inherited from cldnn::primitive_base< normalize, cldnn_normalize_desc >
const cldnn_primitive_descget_dto () const override
 Returns pointer to a C API primitive descriptor casted to cldnn_primitive_desc.
 
- Public Member Functions inherited from cldnn::primitive
 primitive (const primitive_type_id &type, const primitive_id &id, const std::vector< primitive_id > &input, const padding &output_padding=padding())
 
 primitive (const cldnn_primitive_desc *dto)
 Constructs a copy from basic C API cldnn_primitive_desc.
 
std::vector< std::reference_wrapper< primitive_id > > dependecies ()
 Returns references to all primitive ids on which this primitive depends - inputs, weights, biases, etc.
 
std::vector< primitive_iddependecies () const
 Returns copy of all primitive ids on which this primitive depends - inputs, weights, biases, etc.
 
 operator primitive_id () const
 Implicit conversion to primiitive id.
 

Static Public Member Functions

static primitive_type_id type_id ()
 

Public Attributes

primitive_id scale_input
 Scale input primitive id with values needed for scaling after the normalization. Scale x dimension should be 1 (if all channels have the same scale) or equal to input feature size (one scale per channel). All other dimensions should be 1.
 
bool across_spatial
 Determines if the normalization is done across or within spatial (see documentation above).
 
float epsilon
 Epsilon for not dividing by zero while normalizing.
 
- Public Attributes inherited from cldnn::primitive
const primitive_type_id type
 Primitive's type id.
 
const primitive_id id
 Primitive's id.
 
fixed_size_vector_ref input
 List of ids of input primitives.
 
padding output_padding
 Requested output padding.
 

Protected Member Functions

std::vector< std::reference_wrapper< const primitive_id > > get_dependencies () const override
 
void update_dto (dto &dto) const override
 
- Protected Member Functions inherited from cldnn::primitive_base< normalize, cldnn_normalize_desc >
 primitive_base (const primitive_id &id, const std::vector< primitive_id > &input, const padding &output_padding=padding())
 
 primitive_base (const cldnn_normalize_desc *dto)
 

Additional Inherited Members

- Protected Attributes inherited from cldnn::primitive
primitive_id_arr _input
 

Detailed Description

Normalizes the input using an L2 norm and multiplies the output with scale value. The scale can be equal for all channels or one scale per channel.

The L2 norm is computed as:
Across spatial mode (across_spatial=true)-
norm(i,x,y) = sqrt( Σ( in(f,w,h)^2 ) + epsilon ) where f in range (0,num_of_features), w in range (0,input_width), h in range (0,input_height).
The summation is performed over all the pixels in the batch.
Within spatial mode (across_spatial=false)-
norm(i,x,y) = sqrt( Σ( in(f,x,y)^2 ) + epsilon ) where f in range (0,num_of_features).
The summation is performed over this (x,y) position on all the features.

Algorithm:
out(i,x,y) = ( in(i,x,y) / norm(i,x,y) ) * scale(i)
Where:
  • out(i,x,y) : value at x, y from i-th feature map after normalization.
  • in(i,x,y) : value at x, y from i-th feature map before normalization.
  • norm(i,x,y) : L2 norm as described above.
  • scale(i) : the scale value of the i-th feature map.

Definition at line 47 of file normalize.hpp.

Constructor & Destructor Documentation

◆ normalize()

cldnn::normalize::normalize ( const primitive_id id,
const primitive_id input,
const primitive_id scale_input,
const bool  across_spatial = true,
const float  epsilon = 1e-10f,
const padding output_padding = padding() 
)
inline

Constructs normalize primitive.

Parameters
idThis primitive id.
inputInput primitive id.
scale_inputScale input primitive id with values needed for scaling after the normalization. Scale x dimension should be 1 (if all channels have the same scale) or equal to input feature size (one scale per channel). All other dimensions should be 1.
across_spatialDetermines if the normalization is done across or within spatial (see documentation above).
epsilonEpsilon for not dividing by zero while normalizing.

Definition at line 59 of file normalize.hpp.


The documentation for this struct was generated from the following file: