aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/reference/NormalizationLayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/validation/reference/NormalizationLayer.cpp')
-rw-r--r--tests/validation/reference/NormalizationLayer.cpp120
1 files changed, 0 insertions, 120 deletions
diff --git a/tests/validation/reference/NormalizationLayer.cpp b/tests/validation/reference/NormalizationLayer.cpp
index 85872c8f90..2ae68c63cf 100644
--- a/tests/validation/reference/NormalizationLayer.cpp
+++ b/tests/validation/reference/NormalizationLayer.cpp
@@ -24,7 +24,6 @@
#include "NormalizationLayer.h"
#include "arm_compute/core/Types.h"
-#include "tests/validation/FixedPoint.h"
namespace arm_compute
{
@@ -146,125 +145,6 @@ SimpleTensor<T> normalization_layer(const SimpleTensor<T> &src, NormalizationLay
return dst;
}
-template <typename T, typename std::enable_if<std::is_integral<T>::value, int>::type>
-SimpleTensor<T> normalization_layer(const SimpleTensor<T> &src, NormalizationLayerInfo info)
-{
- using namespace fixed_point_arithmetic;
-
- // Create reference
- SimpleTensor<T> dst{ src.shape(), src.data_type(), 1 };
-
- // Compute reference
- const int fixed_point_position = src.fixed_point_position();
-
- const uint32_t norm_size = info.norm_size();
- NormType type = info.type();
- fixed_point<T> beta(info.beta(), fixed_point_position);
- fixed_point<T> kappa(info.kappa(), fixed_point_position);
-
- const int cols = src.shape()[0];
- const int rows = src.shape()[1];
- const int depth = src.shape()[2];
- int upper_dims = src.shape().total_size() / (cols * rows);
-
- fixed_point<T> coeff(info.scale_coeff(), fixed_point_position);
- int radius_cols = norm_size / 2;
-
- // IN_MAP_1D and CROSS_MAP normalize over a single axis only
- int radius_rows = (NormType::IN_MAP_2D == type) ? norm_size / 2 : 0;
-
- if(type == NormType::CROSS_MAP)
- {
- // Remove also depth from upper dimensions since it is the dimension we
- // want to use for normalization
- upper_dims /= depth;
-
- for(int r = 0; r < upper_dims; ++r)
- {
- for(int i = 0; i < rows; ++i)
- {
- for(int k = 0; k < cols; ++k)
- {
- for(int l = 0; l < depth; ++l)
- {
- fixed_point<T> accumulated_scale(0.f, fixed_point_position);
-
- for(int j = -radius_cols; j <= radius_cols; ++j)
- {
- const int z = l + j;
-
- if(z >= 0 && z < depth)
- {
- const T value = src[k + i * cols + z * rows * cols + r * cols * rows * depth];
- const fixed_point<T> fp_value(value, fixed_point_position, true);
- accumulated_scale = add(accumulated_scale, mul(fp_value, fp_value));
- }
- }
-
- accumulated_scale = add(kappa, mul(accumulated_scale, coeff));
- dst[k + i * cols + l * rows * cols + r * cols * rows * depth] = accumulated_scale.raw();
- }
- }
- }
- }
- }
- else
- {
- for(int r = 0; r < upper_dims; ++r)
- {
- for(int i = 0; i < rows; ++i)
- {
- for(int k = 0; k < cols; ++k)
- {
- fixed_point<T> accumulated_scale(0.f, fixed_point_position);
-
- for(int j = -radius_rows; j <= radius_rows; ++j)
- {
- const int y = i + j;
-
- for(int l = -radius_cols; l <= radius_cols; ++l)
- {
- const int x = k + l;
-
- if((x >= 0 && y >= 0) && (x < cols && y < rows))
- {
- const T value = src[x + y * cols + r * cols * rows];
- const fixed_point<T> fp_value(value, fixed_point_position, true);
- accumulated_scale = add(accumulated_scale, mul(fp_value, fp_value));
- }
- }
- }
-
- accumulated_scale = add(kappa, mul(accumulated_scale, coeff));
- dst[k + i * cols + r * cols * rows] = accumulated_scale.raw();
- }
- }
- }
- }
-
- if(info.beta() == 1.f)
- {
- for(int i = 0; i < dst.num_elements(); ++i)
- {
- fixed_point<T> res = div(fixed_point<T>(src[i], fixed_point_position, true), fixed_point<T>(dst[i], fixed_point_position, true));
- dst[i] = res.raw();
- }
- }
- else
- {
- const fixed_point<T> beta(info.beta(), fixed_point_position);
-
- for(int i = 0; i < dst.num_elements(); ++i)
- {
- fixed_point<T> res = pow(fixed_point<T>(dst[i], fixed_point_position, true), beta);
- res = div(fixed_point<T>(src[i], fixed_point_position, true), res);
- dst[i] = res.raw();
- }
- }
-
- return dst;
-}
-
template SimpleTensor<float> normalization_layer(const SimpleTensor<float> &src, NormalizationLayerInfo info);
template SimpleTensor<half> normalization_layer(const SimpleTensor<half> &src, NormalizationLayerInfo info);
} // namespace reference