diff --git a/paddle/phi/kernels/gpu/grid_sample_kernel.cu b/paddle/phi/kernels/gpu/grid_sample_kernel.cu index 3809ae7d5c3388..01ea8ab8be3b32 100644 --- a/paddle/phi/kernels/gpu/grid_sample_kernel.cu +++ b/paddle/phi/kernels/gpu/grid_sample_kernel.cu @@ -154,8 +154,8 @@ __global__ void GridSampleCudaKernel(const int nthreads, } } } else if (mode == Mode::nearest) { - int ix_nearest = static_cast(std::nearbyint(ix)); - int iy_nearest = static_cast(std::nearbyint(iy)); + int ix_nearest = static_cast(std::round(ix)); + int iy_nearest = static_cast(std::round(iy)); auto inp_offset_NC = n * inp_sN; auto out_ptr_NCHW = output + n * out_sN + h * out_sH + w * out_sW; for (int c = 0; c < out_c;