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

Function s16_sve_scale_nearest

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

Source from the content-addressed store, hash-verified

94}
95
96void s16_sve_scale_nearest(const ITensor *src,
97 ITensor *dst,
98 const ITensor *offsets,
99 float sampling_offset,
100 bool align_corners,
101 const Window &window)
102{
103 const size_t in_stride_c = src->info()->dimension(0) + src->info()->padding().left + src->info()->padding().right;
104 const size_t in_stride_w = src->info()->dimension(1) + src->info()->padding().top + src->info()->padding().bottom;
105 const size_t in_stride_wc = in_stride_w * in_stride_c;
106 const size_t in_dim_h = src->info()->dimension(2);
107
108 // Compute the ratio between source height and destination height
109 const auto hr = scale_utils::calculate_resize_ratio(in_dim_h, dst->info()->dimension(2), align_corners);
110 const auto window_start_x = static_cast<int32_t>(window.x().start());
111 const auto window_end_x = static_cast<int32_t>(window.x().end());
112
113 Window win(window);
114 win.set(Window::DimX, Window::Dimension(0, 1, 1));
115 Iterator out(dst, win);
116
117 const uint8_t *in_ptr_start = src->buffer() + src->info()->offset_first_element_in_bytes();
118 const unsigned int in_stride_bytes_hwc = src->info()->strides_in_bytes()[3];
119
120 execute_window_loop(
121 win,
122 [&](const Coordinates &id)
123 {
124 const int32_t offset =
125 *reinterpret_cast<const int32_t *>(offsets->ptr_to_element(Coordinates(id.y(), id.z()))) * in_stride_c;
126 const auto in_hi = static_cast<int>(
127 align_corners ? utils::rounding::round_half_away_from_zero((id.z() + sampling_offset) * hr)
128 : std::floor((id.z() + sampling_offset) * hr));
129 const int offset_row = in_hi * in_stride_wc;
130 const auto in_ptr = reinterpret_cast<const int16_t *>(in_ptr_start + in_stride_bytes_hwc * id[3]);
131 const auto out_ptr = reinterpret_cast<int16_t *>(out.ptr());
132
133 // Compute S elements per iteration
134 int x = window_start_x;
135 svbool_t pg = svwhilelt_b16(x, window_end_x);
136 do
137 {
138 // Store results
139 svst1_s16(pg, out_ptr + x, svld1_s16(pg, in_ptr + offset + offset_row + x));
140
141 x += svcntw();
142 pg = svwhilelt_b16(x, window_end_x);
143 } while (svptest_any(svptrue_b16(), pg));
144 },
145 out);
146}
147} // namespace
148namespace cpu
149{

Callers 1

s16_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