diff --git a/paddle/phi/kernels/gpu/batch_norm_grad_kernel.cu b/paddle/phi/kernels/gpu/batch_norm_grad_kernel.cu index be78b741c7269a295e8c61171a23e8d78c7b19ed..78e8bf4fc26bda5fa5a24d135cb6240cd7cf23c5 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);