37 template <
typename T,
int S>
43 const auto window_start_x =
static_cast<int>(window.
x().
start());
44 const auto window_end_x =
static_cast<int>(window.
x().
end());
49 Iterator input_it(in, win_collapsed);
51 Iterator output_it(out, win_collapsed);
55 const auto in_ptr =
reinterpret_cast<const T *
>(input_it.
ptr());
56 const auto out_ptr =
reinterpret_cast<T *
>(output_it.
ptr());
58 const T sum_value = *
reinterpret_cast<const T *
>(sum_it.
ptr());
59 const T norm_value =
static_cast<T
>(1.f) / std::sqrt(std::max(sum_value, static_cast<T>(epsilon)));
60 const auto vec_norm_value =
wrapper::vdup_n(norm_value, ExactTagType{});
63 int x = window_start_x;
64 for(; x <= (window_end_x - window_step_x); x += window_step_x)
70 for(; x < window_end_x; ++x)
72 out_ptr[x] = in_ptr[x] * norm_value;
75 input_it, sum_it, output_it);
78 template <
typename T,
int S>
84 const auto window_start_x =
static_cast<int>(window.
x().
start());
85 const auto window_end_x =
static_cast<int>(window.
x().
end());
97 const auto vec_eps =
wrapper::vdup_n(static_cast<T>(epsilon), ExactTagType{});
101 const auto in_ptr =
reinterpret_cast<const T *
>(input_it.
ptr());
102 const auto sum_ptr =
reinterpret_cast<const T *
>(sum_it.
ptr());
103 const auto out_ptr =
reinterpret_cast<T *
>(output_it.
ptr());
106 int x = window_start_x;
107 for(; x <= (window_end_x - window_step_x); x += window_step_x)
114 for(; x < window_end_x; ++x)
116 const T norm_value =
static_cast<T
>(1.f) / std::sqrt(std::max(sum_ptr[x], static_cast<T>(epsilon)));
117 out_ptr[x] = in_ptr[x] * norm_value;
120 input_it, sum_it, output_it);
126 #if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && defined(ENABLE_FP16_KERNELS) 129 #endif //defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && defined(ENABLE_FP16_KERNELS) void l2_normalize_yz(const ITensor *in, const ITensor *sum, ITensor *out, float epsilon, const Window &window, size_t axis)
void l2_normalize_x(const ITensor *in, const ITensor *sum, ITensor *out, float epsilon, const Window &window)
template void l2_normalize_yz< float, 4 >(const ITensor *in, const ITensor *sum, ITensor *out, float epsilon, const Window &window, size_t axis)
float32x2_t vinvsqrt(const float32x2_t &a)
uint8x16_t vloadq(const uint8_t *ptr)
virtual DataType data_type() const =0
Data type used for each element of the tensor.
Describe one of the image's dimensions with a start, end and step.
Interface for CPU tensor.
Copyright (c) 2017-2022 Arm Limited.
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Window collapse_if_possible(const Window &full_window, size_t first, size_t last, bool *has_collapsed=nullptr) const
Collapse the dimensions between first and last if possible.
Create the appropriate SIMD vector given its type and size in terms of elements.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
size_t data_size_from_type(DataType data_type)
The size in bytes of the data type.
constexpr uint8_t * ptr() const
Return a pointer to the current pixel.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
template void l2_normalize_x< float, 4 >(const ITensor *in, const ITensor *sum, ITensor *out, float epsilon, const Window &window)
uint8x8_t vmul(const uint8x8_t &a, const uint8x8_t &b)
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
void vstore(uint8_t *ptr, uint8x8_t val)
uint8x8_t vdup_n(uint8_t value, traits::vector_64_tag)
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...
Includes all wrapper headers at once.
constexpr int end() const
Return the end of the dimension.
Iterator updated by execute_window_loop for each window element.
uint8x8_t vmax(const uint8x8_t &a, const uint8x8_t &b)
constexpr int start() const
Return the start of the dimension.
Describe a multidimensional execution window.
constexpr const Dimension & x() const
Alias to access the first dimension of the window.