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

Function u8_neon_scale_nearest

src/cpu/kernels/scale/neon/integer.cpp:38–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36namespace
37{
38void u8_neon_scale_nearest(const ITensor *src,
39 ITensor *dst,
40 const ITensor *offsets,
41 float sampling_offset,
42 bool align_corners,
43 const Window &window)
44{
45 const size_t in_stride_c = src->info()->dimension(0) + src->info()->padding().left + src->info()->padding().right;
46 const size_t in_stride_w = src->info()->dimension(1) + src->info()->padding().top + src->info()->padding().bottom;
47 const size_t in_stride_wc = in_stride_w * in_stride_c;
48 const size_t in_dim_h = src->info()->dimension(2);
49
50 // Compute the ratio between source height and destination height
51 const auto hr = scale_utils::calculate_resize_ratio(in_dim_h, dst->info()->dimension(2), align_corners);
52 const auto window_start_x = static_cast<int32_t>(window.x().start());
53 const auto window_end_x = static_cast<int32_t>(window.x().end());
54 const int window_step_x = 16;
55
56 Window win(window);
57 win.set(Window::DimX, Window::Dimension(0, 1, 1));
58 Iterator out(dst, win);
59
60 const uint8_t *in_ptr_start = src->buffer() + src->info()->offset_first_element_in_bytes();
61 const unsigned int in_stride_bytes_hwc = src->info()->strides_in_bytes()[3];
62
63 execute_window_loop(
64 win,
65 [&](const Coordinates &id)
66 {
67 const int32_t offset =
68 *reinterpret_cast<const int32_t *>(offsets->ptr_to_element(Coordinates(id.y(), id.z()))) * in_stride_c;
69 const auto in_hi = static_cast<int>(
70 align_corners ? utils::rounding::round_half_away_from_zero((id.z() + sampling_offset) * hr)
71 : std::floor((id.z() + sampling_offset) * hr));
72 const int offset_row = in_hi * in_stride_wc;
73 int32_t x = window_start_x;
74 const uint8_t *in_ptr = reinterpret_cast<const uint8_t *>(in_ptr_start + in_stride_bytes_hwc * id[3]);
75
76 for (; x <= window_end_x - window_step_x; x += window_step_x)
77 {
78 wrapper::vstore(reinterpret_cast<uint8_t *>(out.ptr()) + x,
79 wrapper::vloadq(in_ptr + offset + offset_row + x));
80 }
81 for (; x < window_end_x; ++x)
82 {
83 *(reinterpret_cast<uint8_t *>(out.ptr()) + x) = *(in_ptr + offset + offset_row + x);
84 }
85 },
86 out);
87}
88
89void u8_neon_scale_bilinear(const ITensor *src,
90 ITensor *dst,

Callers 1

u8_neon_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