From e1e8bf72031f77adfd44c843bfdc0f4b9541a62e Mon Sep 17 00:00:00 2001 From: xiongkun Date: Tue, 6 Dec 2022 18:48:51 +0800 Subject: [PATCH] make bilinear interpolate stable. (#48644) * make bilinear interpolate stable. * fix code --- .../kernels/gpu/interpolate_grad_kernel.cu | 42 ++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/paddle/phi/kernels/gpu/interpolate_grad_kernel.cu b/paddle/phi/kernels/gpu/interpolate_grad_kernel.cu index b38cae82968..cb1d959e30a 100644 --- a/paddle/phi/kernels/gpu/interpolate_grad_kernel.cu +++ b/paddle/phi/kernels/gpu/interpolate_grad_kernel.cu @@ -25,6 +25,8 @@ #include "paddle/phi/kernels/funcs/math_function.h" #include "paddle/phi/kernels/primitive/datamover_primitives.h" +DECLARE_bool(cudnn_deterministic); + namespace phi { template @@ -1034,6 +1036,12 @@ static void Interpolate2DCUDABwd( #endif if (optimize_flag & is_nchw) { + if (FLAGS_cudnn_deterministic) { + VLOG(2) + << "Run grad kernel of bilinear interpolate 2d with single thread."; + config.block_per_grid = 1; + config.thread_per_block = 1; + } KeBilinearInterpBwShareMemory<< - <<>>(input_grad_data, - in_h, - in_w, - out_h, - out_w, - n, - c, - ratio_h, - ratio_w, - output_grad_data, - align_type_value); + <<>>( + input_grad_data, + in_h, + in_w, + out_h, + out_w, + n, + c, + ratio_h, + ratio_w, + output_grad_data, + align_type_value); } else { int64_t cw = c * out_w; auto interp_divmods = funcs::FastDivModForInterpolate(c, out_chw, cw); -- GitLab