From 72bd1ff1a2c096440156e787e250edcd68d1792f Mon Sep 17 00:00:00 2001 From: wangna11 Date: Tue, 14 Nov 2023 08:51:03 +0000 Subject: [PATCH] fix grid_sample bug --- paddle/phi/kernels/gpu/grid_sample_kernel.cu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/phi/kernels/gpu/grid_sample_kernel.cu b/paddle/phi/kernels/gpu/grid_sample_kernel.cu index 3809ae7d5c338..01ea8ab8be3b3 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;