From 2127790445b29f2b9440bafb0131fa73b87032b8 Mon Sep 17 00:00:00 2001 From: wanghuancoder Date: Thu, 3 Nov 2022 19:10:31 +0800 Subject: [PATCH] Weight and bias's stop_gradient of BatchNorm must be True or False at the same time (#47634) --- paddle/phi/kernels/gpu/batch_norm_grad_kernel.cu | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/paddle/phi/kernels/gpu/batch_norm_grad_kernel.cu b/paddle/phi/kernels/gpu/batch_norm_grad_kernel.cu index be78b741c7..78e8bf4fc2 100644 --- a/paddle/phi/kernels/gpu/batch_norm_grad_kernel.cu +++ b/paddle/phi/kernels/gpu/batch_norm_grad_kernel.cu @@ -605,6 +605,14 @@ void BatchNormGradRawKernel(const Context &ctx, "the dimensions of input is [%s]", x_dims.size(), x_dims)); + + PADDLE_ENFORCE_EQ((d_scale == nullptr && d_bias == nullptr) || + (d_scale != nullptr && d_bias != nullptr), + true, + phi::errors::InvalidArgument( + "Weight and bias's stop_gradient of BatchNorm must be " + "True or False at the same time.")); + int N, C, H, W, D; phi::funcs::ExtractNCWHD(x_dims, data_layout, &N, &C, &H, &W, &D); -- GitLab