| 68 | // bilinear resampling |
| 69 | template<typename T, typename VT> |
| 70 | void resize_b_(T* d_out, const KParam out, const T* d_in, const KParam in, |
| 71 | const int blockIdx_x, const int blockIdx_y, const float xf_, |
| 72 | const float yf_, sycl::nd_item<2>& it) { |
| 73 | sycl::group g = it.get_group(); |
| 74 | |
| 75 | int const ox = it.get_local_id(0) + blockIdx_x * g.get_local_range(0); |
| 76 | int const oy = it.get_local_id(1) + blockIdx_y * g.get_local_range(1); |
| 77 | |
| 78 | float xf = ox * xf_; |
| 79 | float yf = oy * yf_; |
| 80 | |
| 81 | int ix = sycl::floor(xf); |
| 82 | |
| 83 | int iy = sycl::floor(yf); |
| 84 | |
| 85 | if (ox >= out.dims[0] || oy >= out.dims[1]) { return; } |
| 86 | if (ix >= in.dims[0]) { ix = in.dims[0] - 1; } |
| 87 | if (iy >= in.dims[1]) { iy = in.dims[1] - 1; } |
| 88 | |
| 89 | float b = xf - ix; |
| 90 | float a = yf - iy; |
| 91 | |
| 92 | const int ix2 = (ix + 1) < in.dims[0] ? (ix + 1) : ix; |
| 93 | const int iy2 = (iy + 1) < in.dims[1] ? (iy + 1) : iy; |
| 94 | |
| 95 | const VT p1 = d_in[ix + in.strides[1] * iy]; |
| 96 | const VT p2 = d_in[ix + in.strides[1] * iy2]; |
| 97 | const VT p3 = d_in[ix2 + in.strides[1] * iy]; |
| 98 | const VT p4 = d_in[ix2 + in.strides[1] * iy2]; |
| 99 | |
| 100 | d_out[ox + oy * out.strides[1]] = |
| 101 | mul(((1.0f - a) * (1.0f - b)), p1) + mul(((a) * (1.0f - b)), p2) + |
| 102 | mul(((1.0f - a) * (b)), p3) + mul(((a) * (b)), p4); |
| 103 | } |
| 104 | |
| 105 | //////////////////////////////////////////////////////////////////////////////////// |
| 106 | // lower resampling |