Compute Library
 19.08
GCBatchNormalizationLayer Class Reference

Basic function to run GCBatchNormalizationLayerKernel and simulate a batch normalization layer. More...

#include <GCBatchNormalizationLayer.h>

Collaboration diagram for GCBatchNormalizationLayer:
[legend]

Public Member Functions

 GCBatchNormalizationLayer ()
 Default constructor. More...
 
void configure (const IGCTensor *input, IGCTensor *output, const IGCTensor *mean, const IGCTensor *var, const IGCTensor *beta, const IGCTensor *gamma, float epsilon, ActivationLayerInfo act_info=ActivationLayerInfo())
 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 run GCBatchNormalizationLayerKernel and simulate a batch normalization layer.

Batch normalization is calculated by:

\[ out_i = \gamma * (\frac{in_i - \mu_{B}}{\sqrt{\sigma^2_{B} + \epsilon}}) + \beta \equiv BN_{\gamma,\beta}(in_i) \]

Definition at line 42 of file GCBatchNormalizationLayer.h.

Constructor & Destructor Documentation

◆ GCBatchNormalizationLayer()

Default constructor.

Definition at line 35 of file GCBatchNormalizationLayer.cpp.

36  : _norm_kernel()
37 {
38 }

Member Function Documentation

◆ configure()

void configure ( const IGCTensor input,
IGCTensor output,
const IGCTensor mean,
const IGCTensor var,
const IGCTensor beta,
const IGCTensor gamma,
float  epsilon,
ActivationLayerInfo  act_info = ActivationLayerInfo() 
)

Set the input and output tensors.

Parameters
[in]inputSource tensor. 3 lower dimensions represent a single input with dimensions [width, height, FM]. The rest are optional and used for representing batches. Data types supported: F16/F32.
[out]outputDestination tensor. Output will have the same number of dimensions as input. Data type supported: same as input
[in]meanMean values tensor. 1 dimension with size equal to the feature maps [FM]. Data types supported: Same as input
[in]varVariance values tensor. 1 dimension with size equal to the feature maps [FM]. Data types supported: Same as input
[in]betaBeta values tensor. 1 dimension with size equal to the feature maps [FM]. Data types supported: Same as input
[in]gammaGamma values tensor. 1 dimension with size equal to the feature maps [FM]. Data types supported: Same as input
[in]epsilonSmall value to avoid division with zero.
[in]act_info(Optional) Activation layer information in case of a fused activation. Only RELU, BOUNDED_RELU and LU_BOUNDED_RELU supported.

Definition at line 40 of file GCBatchNormalizationLayer.cpp.

42 {
43  _norm_kernel.configure(input, output, mean, var, beta, gamma, epsilon, act_info);
44 }
constexpr float epsilon
void configure(const IGCTensor *input, IGCTensor *output, const IGCTensor *mean, const IGCTensor *var, const IGCTensor *beta=nullptr, const IGCTensor *gamma=nullptr, float epsilon=0.001f, ActivationLayerInfo act_info=ActivationLayerInfo())
Set the input and output tensors.

References arm_compute::test::validation::act_info, GCBatchNormalizationLayerKernel::configure(), and epsilon.

◆ 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 46 of file GCBatchNormalizationLayer.cpp.

47 {
48  GCScheduler::get().dispatch(_norm_kernel, true);
49 }
void dispatch(IGCKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
Definition: GCScheduler.cpp:69
static GCScheduler & get()
Access the scheduler singleton.
Definition: GCScheduler.cpp:62

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


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