Skip to content

Commit 90d05bb

Browse files
Fix sum op fails as no memory in tensor(#20602) (#20659)
test=develop Signed-off-by: zhaoyuchen <[email protected]>
1 parent 5a64b5a commit 90d05bb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

paddle/fluid/operators/sum_op.cu

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,10 @@ void SumToLoDTensor(const framework::ExecutionContext &context) {
163163
for (int i = start; i < in_num; ++i) {
164164
if (in_vars[i]->IsType<framework::LoDTensor>()) {
165165
auto &in_i = in_vars[i]->Get<framework::LoDTensor>();
166-
in_data.emplace_back(in_i.data<T>());
167166
lod_length = in_i.numel();
167+
if (lod_length && in_i.IsInitialized()) {
168+
in_data.emplace_back(in_i.data<T>());
169+
}
168170
} else if (in_vars[i]->IsType<framework::SelectedRows>()) {
169171
selectrow_index.push_back(i);
170172
}

0 commit comments

Comments
 (0)