diff --git a/paddle/fluid/operators/sum_op.cu b/paddle/fluid/operators/sum_op.cu index 3564ed0c4f0faf45461374ba1faa68c1c7992cb6..fa6ae65a0e75d365cccd6d8b5efd1eac3132e978 100644 --- a/paddle/fluid/operators/sum_op.cu +++ b/paddle/fluid/operators/sum_op.cu @@ -163,8 +163,10 @@ void SumToLoDTensor(const framework::ExecutionContext &context) { for (int i = start; i < in_num; ++i) { if (in_vars[i]->IsType()) { auto &in_i = in_vars[i]->Get(); - in_data.emplace_back(in_i.data()); lod_length = in_i.numel(); + if (lod_length && in_i.IsInitialized()) { + in_data.emplace_back(in_i.data()); + } } else if (in_vars[i]->IsType()) { selectrow_index.push_back(i); }