43 const uint32_t norm_size = info.
norm_size();
45 float beta = info.
beta();
46 uint32_t kappa = info.
kappa();
50 const int depth = src.
shape()[2];
51 int upper_dims = src.
shape().total_size() / (cols *
rows);
54 int radius_cols = norm_size / 2;
65 for(
int r = 0; r < upper_dims; ++r)
67 for(
int i = 0; i <
rows; ++i)
69 for(
int k = 0; k <
cols; ++k)
71 for(
int l = 0; l < depth; ++l)
73 float accumulated_scale = 0.f;
75 for(
int j = -radius_cols; j <= radius_cols; ++j)
79 if(z >= 0 && z < depth)
81 const T value = src[k + i * cols + z * rows * cols + r * cols * rows * depth];
82 accumulated_scale += value * value;
86 dst[k + i * cols + l * rows * cols + r * cols * rows * depth] = kappa + accumulated_scale * coeff;
94 for(
int r = 0; r < upper_dims; ++r)
96 for(
int i = 0; i <
rows; ++i)
98 for(
int k = 0; k <
cols; ++k)
100 float accumulated_scale = 0.f;
102 for(
int j = -radius_rows; j <= radius_rows; ++j)
105 for(
int l = -radius_cols; l <= radius_cols; ++l)
109 if((x >= 0 && y >= 0) && (x < cols && y <
rows))
111 const T value = src[x + y * cols + r * cols *
rows];
112 accumulated_scale += value * value;
117 dst[k + i * cols + r * cols *
rows] = kappa + accumulated_scale * coeff;
125 for(
int i = 0; i <
dst.num_elements(); ++i)
130 else if(beta == 0.5f)
132 for(
int i = 0; i <
dst.num_elements(); ++i)
134 dst[i] = src[i] / std::sqrt(
dst[i]);
139 for(
int i = 0; i <
dst.num_elements(); ++i)
141 dst[i] = src[i] * std::exp(std::log(
dst[i]) * -beta);
float scale_coeff() const
Return the scaling factor of the normalization function.
float kappa() const
Get the kappa value.
uint32_t norm_size() const
Get the normalization size.
NormType type() const
Get the normalization type.
DataType data_type() const override
Data type of the tensor.
Normalization Layer Information class.
bool is_cross_map() const
Check if normalization is cross map.
TensorShape shape() const override
Shape of the tensor.
decltype(strategy::transforms) typedef type
SimpleTensor< float > src
Copyright (c) 2017-2021 Arm Limited.
float beta() const
Get the beta value.
Simple tensor object that stores elements in a consecutive chunk of memory.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
SimpleTensor< T > normalization_layer(const SimpleTensor< T > &src, NormalizationLayerInfo info)
NormType
The normalization type used for the normalization layer.
Normalization applied within the same map in 2D region.