Skip to content

Commit

Permalink
skip CopyOrAdd when tmp grad is None (PaddlePaddle#55679)
Browse files Browse the repository at this point in the history
  • Loading branch information
FeixLiu authored Jul 26, 2023
1 parent 2ade1f9 commit e838a4b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion paddle/fluid/eager/accumulation/accumulation_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ GradNodeAccumulation::operator()(

if (!weak_grad_.expired() && !is_new_grad) {
auto grad = weak_grad_.lock();
CopyOrAddTensor(grad.get(), grad_out, is_fake_empty_);
if (grad_out.defined() && grad_out.initialized()) {
CopyOrAddTensor(grad.get(), grad_out, is_fake_empty_);
}
// else { do nothing since there is no valid value in grad out tensor }
is_fake_empty_ = false;
}

Expand Down

0 comments on commit e838a4b

Please sign in to comment.