24.02.1
|
Go to the documentation of this file.
33 template <
typename ScalarType,
int size>
42 const int window_step_x = size;
43 const auto window_start_x =
static_cast<int>(window.
x().
start());
44 const auto window_end_x =
static_cast<int>(window.
x().
end());
53 int x = window_start_x;
54 auto in_ptr =
reinterpret_cast<const ScalarType *
>(input_itr.
ptr());
55 auto out_ptr =
reinterpret_cast<ScalarType *
>(output_itr.
ptr());
57 auto sum_vec =
wrapper::vdup_n(
static_cast<ScalarType
>(0.f), ExactTagType{});
58 auto sum_sq_vec =
wrapper::vdup_n(
static_cast<ScalarType
>(0.f), ExactTagType{});
60 for (; x <= (window_end_x - window_step_x); x += window_step_x)
69 for (
int i = 0; i < size / 4; ++i)
72 sum_sq_carry_res =
wrapper::vpadd(sum_sq_carry_res, sum_sq_carry_res);
79 for (; x < window_end_x; ++x)
81 ScalarType data = *(in_ptr + x);
83 sum_sq += data * data;
86 ScalarType mean = sum /
input->info()->dimension(0);
87 ScalarType var = (sum_sq /
input->info()->dimension(0)) - (mean * mean);
88 ScalarType stddev_inv = 1.f / sqrt(var +
epsilon);
92 for (x = window_start_x; x <= (window_end_x - window_step_x); x += window_step_x)
99 for (; x < window_end_x; ++x)
101 *(out_ptr + x) = (*(in_ptr + x) - mean) * stddev_inv;
104 input_itr, output_itr);
uint8x8_t vadd(const uint8x8_t &a, const uint8x8_t &b)
constexpr int start() const
Return the start of the dimension.
uint8x8_t vsub(const uint8x8_t &a, const uint8x8_t &b)
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
uint8_t vgetlane(const uint8x8_t vector, const unsigned int lane)
void mean_stddev_normalization(ITensor *input, ITensor *output, float epsilon, const Window &window)
Interface for CPU tensor.
uint8x16_t vloadq(const uint8_t *ptr)
Includes all wrapper headers at once.
uint8x8_t vpadd(const uint8x8_t &a, const uint8x8_t &b)
Create the appropriate SIMD vector given its type and size in terms of elements.
constexpr uint8_t * ptr() const
Return a pointer to the current pixel.
uint8x8_t vmul(const uint8x8_t &a, const uint8x8_t &b)
void execute_window_loop(const Window &w, L &&lambda_function, Ts &&...iterators)
Iterate through the passed window, automatically adjusting the iterators and calling the lambda_funct...
Iterator updated by execute_window_loop for each window element.
Describe one of the image's dimensions with a start, end and step.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
uint8x8_t vgetlow(const uint8x16_t val)
void vstore(uint8_t *ptr, uint8x8_t val)
Describe a multidimensional execution window.
Copyright (c) 2017-2024 Arm Limited.
constexpr int end() const
Return the end of the dimension.
template void mean_stddev_normalization< float, 4 >(ITensor *input, ITensor *output, float epsilon, const Window &window)
uint8x8_t vgethigh(const uint8x16_t val)
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
uint8x8_t vdup_n(uint8_t value, traits::vector_64_tag)