24.02.1
|
Go to the documentation of this file.
24 #ifndef SRC_CORE_NEON_KERNELS_ADD_IMPL_H
25 #define SRC_CORE_NEON_KERNELS_ADD_IMPL_H
38 template <
typename ScalarType>
53 constexpr
int window_step_x = 16 /
sizeof(ScalarType);
54 const auto window_start_x =
static_cast<int>(window.
x().
start());
55 const auto window_end_x =
static_cast<int>(window.
x().
end());
58 if (is_broadcast_across_x)
60 const bool is_broadcast_input_2 = input2_win.
x().
step() == 0;
61 Window broadcast_win = is_broadcast_input_2 ? input2_win : input1_win;
62 Window non_broadcast_win = !is_broadcast_input_2 ? input2_win : input1_win;
63 const ITensor *broadcast_tensor = is_broadcast_input_2 ? src1 : src0;
64 const ITensor *non_broadcast_tensor = !is_broadcast_input_2 ? src1 : src0;
69 Iterator broadcast_input(broadcast_tensor, broadcast_win);
70 Iterator non_broadcast_input(non_broadcast_tensor, non_broadcast_win);
77 const auto non_broadcast_input_ptr =
reinterpret_cast<const ScalarType *
>(non_broadcast_input.
ptr());
78 const auto output_ptr =
reinterpret_cast<ScalarType *
>(output.
ptr());
80 const ScalarType broadcast_value = *
reinterpret_cast<const ScalarType *
>(broadcast_input.
ptr());
81 const auto broadcast_value_vec =
wrapper::vdup_n(broadcast_value, ExactTagType{});
84 int x = window_start_x;
85 for (; x <= (window_end_x - window_step_x); x += window_step_x)
87 const auto non_broadcast_v =
wrapper::vloadq(non_broadcast_input_ptr + x);
95 for (; x < window_end_x; ++x)
97 const auto non_broadcast_v = *(non_broadcast_input_ptr + x);
100 : broadcast_value + non_broadcast_v;
103 broadcast_input, non_broadcast_input, output);
119 const auto input1_ptr =
reinterpret_cast<const ScalarType *
>(input1.
ptr());
120 const auto input2_ptr =
reinterpret_cast<const ScalarType *
>(input2.
ptr());
121 const auto output_ptr =
reinterpret_cast<ScalarType *
>(output.
ptr());
124 int x = window_start_x;
125 for (; x <= (window_end_x - window_step_x); x += window_step_x)
135 for (; x < window_end_x; ++x)
137 const auto val1 = *(input1_ptr + x);
138 const auto val2 = *(input2_ptr + x);
143 input1, input2, output);
170 template <
typename ScalarType>
174 template <
typename ScalarType>
183 #endif // SRC_CORE_NEON_KERNELS_ADD_IMPL_H
uint8x8_t vadd(const uint8x8_t &a, const uint8x8_t &b)
constexpr int start() const
Return the start of the dimension.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
constexpr int step() const
Return the step of the dimension.
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
void add_same_neon(const ITensor *src0, const ITensor *src1, ITensor *dst, const ConvertPolicy &policy, const Window &window)
bool sub_q8_neon_fixedpoint_possible(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst)
Interface for CPU tensor.
uint8x16_t vloadq(const uint8_t *ptr)
uint8_t add_sat(const uint8_t &a, const uint8_t &b)
bool add_sub_q8_neon_fixedpoint_possible(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst, bool is_addition)
Includes all wrapper headers at once.
uint8x8_t vqadd(const uint8x8_t &a, const uint8x8_t &b)
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
constexpr uint8_t * ptr() const
Return a pointer to the current pixel.
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.
T x() const
Alias to access the size of the first dimension.
void add_sub_qasymm8_signed_neon(const ITensor *src0, const ITensor *src1, ITensor *dst, const ConvertPolicy &policy, const Window &window, bool is_addition)
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.
void add_q8_neon_fixedpoint(const ITensor *src0, const ITensor *src1, ITensor *dst, const ConvertPolicy &policy, const Window &window)
void vstore(uint8_t *ptr, uint8x8_t val)
Describe a multidimensional execution window.
typename neon_bitvector< T, BW >::tag_type neon_bitvector_tag_t
Helper type template to get the tag type of a neon vector.
Copyright (c) 2017-2024 Arm Limited.
ConvertPolicy
Policy to handle integer overflow.
Window broadcast_if_dimension_le_one(const TensorShape &shape) const
Don't advance in the dimension where shape is less equal to 1.
Store the tensor's metadata.
constexpr int end() const
Return the end of the dimension.
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
bool add_q8_neon_fixedpoint_possible(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst)
uint8x8_t vdup_n(uint8_t value, traits::vector_64_tag)
void add_sub_qasymm8_neon(const ITensor *src0, const ITensor *src1, ITensor *dst, const ConvertPolicy &policy, const Window &window, bool is_addition)
void add_sub_q8_neon_fixedpoint(const ITensor *src0, const ITensor *src1, ITensor *dst, const ConvertPolicy &policy, const Window &window, bool is_addition)