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

Function fp16_sve_scale_nearest

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

Source from the content-addressed store, hash-verified

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

Callers 1

fp16_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