diff --git a/paddle/operators/recv_op.cc b/paddle/operators/recv_op.cc index 07e66492e1411c75c9086a6c6ba88a834f1b840f..731e5e4756a5d6656e001d93e34105d8b81f6d2f 100644 --- a/paddle/operators/recv_op.cc +++ b/paddle/operators/recv_op.cc @@ -95,6 +95,12 @@ class RecvOp : public framework::OperatorBase { } VLOG(10) << "recved grad: " << grad_var_name << " updating param: " << param_var_name; + auto *merged_grad = recv_scope.FindVar(grad_var_name); + if (merged_grad == nullptr) { + // create output of merged var. + recv_scope.Var(grad_var_name); + } + if (trainer_count > 1) { grad_var_name = this->GetGradVarNameForTrainer(grad_var_name); }