42 const int16x8_t three = vdupq_n_s16(3);
43 const int16x8_t minus_three = vdupq_n_s16(-3);
44 const int16x8_t ten = vdupq_n_s16(10);
45 const int16x8_t minus_ten = vdupq_n_s16(-10);
47 inline int16x8_t scharr_y(
const int16x8x2_t &top,
const int16x8x2_t &bottom)
50 int16x8_t out = vmulq_s16(top.val[0], minus_three);
52 out = vmlaq_s16(out, vextq_s16(top.val[0], top.val[1], 1), minus_ten);
54 out = vmlaq_s16(out, vextq_s16(top.val[0], top.val[1], 2), minus_three);
57 out = vmlaq_s16(out, bottom.val[0], three);
59 out = vmlaq_s16(out, vextq_s16(bottom.val[0], bottom.val[1], 1), ten);
61 out = vmlaq_s16(out, vextq_s16(bottom.val[0], bottom.val[1], 2), three);
66 inline int16x8_t scharr_x(
const int16x8x2_t &top,
const int16x8x2_t &middle,
const int16x8x2_t &bottom)
69 int16x8_t out = vmulq_s16(top.val[0], minus_three);
71 out = vmlaq_s16(out, vextq_s16(top.val[0], top.val[1], 2), three);
74 out = vmlaq_s16(out, middle.val[0], minus_ten);
76 out = vmlaq_s16(out, vextq_s16(middle.val[0], middle.val[1], 2), ten);
79 out = vmlaq_s16(out, bottom.val[0], minus_three);
81 out = vmlaq_s16(out, vextq_s16(bottom.val[0], bottom.val[1], 2), three);
88 : _run_scharr_x(false), _run_scharr_y(false), _input(nullptr), _output_x(nullptr), _output_y(nullptr)
97 _run_scharr_x = output_x !=
nullptr;
98 _run_scharr_y = output_y !=
nullptr;
111 _output_x = output_x;
112 _output_y = output_y;
116 constexpr
unsigned int num_elems_read_per_iteration = 16;
117 constexpr
unsigned int num_elems_written_per_iteration = 8;
118 constexpr
unsigned int num_rows_read_per_iteration = 3;
132 INEKernel::configure(win);
156 output_y =
Iterator(_output_y, window);
161 output_x =
Iterator(_output_x, window);
164 if(_run_scharr_x && _run_scharr_y)
169 const uint8x16_t top_data = vld1q_u8(input_top_ptr + input.
offset());
170 const uint8x16_t mid_data = vld1q_u8(input_mid_ptr + input.
offset());
171 const uint8x16_t bot_data = vld1q_u8(input_bot_ptr + input.
offset());
173 const int16x8x2_t top_s16 =
176 vreinterpretq_s16_u16(vmovl_u8(vget_low_u8(top_data))),
177 vreinterpretq_s16_u16(vmovl_u8(vget_high_u8(top_data)))
180 const int16x8x2_t mid_s16 =
183 vreinterpretq_s16_u16(vmovl_u8(vget_low_u8(mid_data))),
184 vreinterpretq_s16_u16(vmovl_u8(vget_high_u8(mid_data)))
187 const int16x8x2_t bot_s16 =
190 vreinterpretq_s16_u16(vmovl_u8(vget_low_u8(bot_data))),
191 vreinterpretq_s16_u16(vmovl_u8(vget_high_u8(bot_data)))
195 vst1q_s16(reinterpret_cast<int16_t *>(output_x.
ptr()), scharr_x(top_s16, mid_s16, bot_s16));
196 vst1q_s16(reinterpret_cast<int16_t *>(output_y.
ptr()), scharr_y(top_s16, bot_s16));
198 input, output_x, output_y);
200 else if(_run_scharr_x)
205 const uint8x16_t top_data = vld1q_u8(input_top_ptr + input.
offset());
206 const uint8x16_t mid_data = vld1q_u8(input_mid_ptr + input.
offset());
207 const uint8x16_t bot_data = vld1q_u8(input_bot_ptr + input.
offset());
209 const int16x8x2_t top_s16 =
212 vreinterpretq_s16_u16(vmovl_u8(vget_low_u8(top_data))),
213 vreinterpretq_s16_u16(vmovl_u8(vget_high_u8(top_data)))
216 const int16x8x2_t mid_s16 =
219 vreinterpretq_s16_u16(vmovl_u8(vget_low_u8(mid_data))),
220 vreinterpretq_s16_u16(vmovl_u8(vget_high_u8(mid_data)))
223 const int16x8x2_t bot_s16 =
226 vreinterpretq_s16_u16(vmovl_u8(vget_low_u8(bot_data))),
227 vreinterpretq_s16_u16(vmovl_u8(vget_high_u8(bot_data)))
231 vst1q_s16(reinterpret_cast<int16_t *>(output_x.
ptr()), scharr_x(top_s16, mid_s16, bot_s16));
235 else if(_run_scharr_y)
240 const uint8x16_t top_data = vld1q_u8(input_top_ptr + input.
offset());
241 const uint8x16_t bot_data = vld1q_u8(input_bot_ptr + input.
offset());
243 const int16x8x2_t top_s16 =
246 vreinterpretq_s16_u16(vmovl_u8(vget_low_u8(top_data))),
247 vreinterpretq_s16_u16(vmovl_u8(vget_high_u8(top_data)))
250 const int16x8x2_t bot_s16 =
253 vreinterpretq_s16_u16(vmovl_u8(vget_low_u8(bot_data))),
254 vreinterpretq_s16_u16(vmovl_u8(vget_high_u8(bot_data)))
258 vst1q_s16(reinterpret_cast<int16_t *>(output_y.
ptr()), scharr_y(top_s16, bot_s16));
unsigned int top
top of the border
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
const Window & window() const
The maximum window the kernel can be executed on.
uint8_t * ptr_to_element(const Coordinates &id) const
Return a pointer to the element at the passed coordinates.
Container for 2D border size.
1 channel, 1 U8 per channel
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Interface for Neon tensor.
Copyright (c) 2017-2021 Arm Limited.
virtual ValidRegion valid_region() const =0
Valid region of the tensor.
Implementation of a rectangular access pattern.
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Class to describe a number of elements in each dimension.
Implementation of a row access pattern.
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.
unsigned int left
left of the border
NEScharr3x3Kernel()
Default constructor.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
1 channel, 1 S16 per channel
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Information about executing thread and CPU.
unsigned int num_elems_processed_per_iteration
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...
void configure(const ITensor *input, ITensor *output_x, ITensor *output_y, bool border_undefined)
Initialise the kernel's source, destination and border.
constexpr size_t offset() const
Return the offset in bytes from the first element to the current position of the iterator.
Iterator updated by execute_window_loop for each window element.
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
Describe a multidimensional execution window.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
BorderSize border_size() const override
The size of the border for that kernel.