From 90d05bbd72bfc583b4e822243407f52ab51595ff Mon Sep 17 00:00:00 2001 From: zhaoyuchen2018 <45989343+zhaoyuchen2018@users.noreply.github.com> Date: Wed, 16 Oct 2019 06:15:24 -0500 Subject: [PATCH] Fix sum op fails as no memory in tensor(#20602) (#20659) test=develop Signed-off-by: zhaoyuchen --- paddle/fluid/operators/sum_op.cu | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/operators/sum_op.cu b/paddle/fluid/operators/sum_op.cu index 3564ed0c4f0..fa6ae65a0e7 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); } -- GitLab