diff --git a/paddle/phi/kernels/gpu/group_norm_grad_kernel.cu b/paddle/phi/kernels/gpu/group_norm_grad_kernel.cu index 37a6adb5f27b2951d8ea8a1140733649f21cfb23..3cbd1d8191cf51be69766da94e97aeeb5ebfdc89 100644 --- a/paddle/phi/kernels/gpu/group_norm_grad_kernel.cu +++ b/paddle/phi/kernels/gpu/group_norm_grad_kernel.cu @@ -291,7 +291,9 @@ void GroupNormGradKernel(const Context& dev_ctx, const int W = (data_layout == DataLayout::kNCHW ? x_dims[x_dims.size() - 1] : x_dims[x_dims.size() - 2]); - dev_ctx.template Alloc(d_x); + if (d_x) { + dev_ctx.template Alloc(d_x); + } phi::funcs::SetConstant set_zero; phi::funcs::SetConstant set_zero_AccT; DenseTensor ds, db;