MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / u8_sve_scale_nearest

Function u8_sve_scale_nearest

src/cpu/kernels/scale/sve/integer.cpp:44–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42namespace
43{
44void u8_sve_scale_nearest(const ITensor *src,
45 ITensor *dst,
46 const ITensor *offsets,
47 float sampling_offset,
48 bool align_corners,
49 const Window &window)
50{
51 const size_t in_stride_c = src->info()->dimension(0) + src->info()->padding().left + src->info()->padding().right;
52 const size_t in_stride_w = src->info()->dimension(1) + src->info()->padding().top + src->info()->padding().bottom;
53 const size_t in_stride_wc = in_stride_w * in_stride_c;
54 const size_t in_dim_h = src->info()->dimension(2);
55
56 // Compute the ratio between source height and destination height
57 const auto hr = scale_utils::calculate_resize_ratio(in_dim_h, dst->info()->dimension(2), align_corners);
58 const auto window_start_x = static_cast<int32_t>(window.x().start());
59 const auto window_end_x = static_cast<int32_t>(window.x().end());
60
61 Window win(window);
62 win.set(Window::DimX, Window::Dimension(0, 1, 1));
63 Iterator out(dst, win);
64
65 const uint8_t *in_ptr_start = src->buffer() + src->info()->offset_first_element_in_bytes();
66 const unsigned int in_stride_bytes_hwc = src->info()->strides_in_bytes()[3];
67
68 execute_window_loop(
69 win,
70 [&](const Coordinates &id)
71 {
72 const int32_t offset =
73 *reinterpret_cast<const int32_t *>(offsets->ptr_to_element(Coordinates(id.y(), id.z()))) * in_stride_c;
74 const auto in_hi = static_cast<int>(
75 align_corners ? utils::rounding::round_half_away_from_zero((id.z() + sampling_offset) * hr)
76 : std::floor((id.z() + sampling_offset) * hr));
77 const int offset_row = in_hi * in_stride_wc;
78 const auto in_ptr = reinterpret_cast<const uint8_t *>(in_ptr_start + in_stride_bytes_hwc * id[3]);
79 const auto out_ptr = reinterpret_cast<uint8_t *>(out.ptr());
80
81 // Compute S elements per iteration
82 int x = window_start_x;
83 svbool_t pg = svwhilelt_b8(x, window_end_x);
84 do
85 {
86 // Store results
87 svst1_u8(pg, out_ptr + x, svld1_u8(pg, in_ptr + offset + offset_row + x));
88
89 x += svcntw();
90 pg = svwhilelt_b8(x, window_end_x);
91 } while (svptest_any(svptrue_b8(), pg));
92 },
93 out);
94}
95
96void s16_sve_scale_nearest(const ITensor *src,
97 ITensor *dst,

Callers 1

u8_sve_scaleFunction · 0.85

Calls 15

floorFunction · 0.85
ptr_to_elementMethod · 0.80
DimensionClass · 0.50
CoordinatesClass · 0.50
dimensionMethod · 0.45
infoMethod · 0.45
paddingMethod · 0.45
startMethod · 0.45
xMethod · 0.45
endMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected