@@ -167,9 +167,8 @@ void ListenAndServOp::RunSyncLoop(
167
167
recv_scope);
168
168
VLOG (2 ) << " run all blocks spent " << GetTimestamp () - ts << " (ms)" ;
169
169
170
- // reset received sparse vars to avoid reuse it in the next mini-batch
171
170
ResetReceivedVars (recv_varnames, recv_scope, dev_ctx,
172
- ! rpc_service_->NeedResetAllVars ());
171
+ rpc_service_->NeedResetAllVars ());
173
172
174
173
rpc_service_->SetCond (distributed::kRequestGet );
175
174
rpc_service_->WaitBarrier (distributed::kRequestGet );
@@ -179,17 +178,19 @@ void ListenAndServOp::RunSyncLoop(
179
178
180
179
void ListenAndServOp::ResetReceivedVars (
181
180
const std::vector<std::string> &recv_varnames, framework::Scope *recv_scope,
182
- platform::DeviceContext *dev_ctx, bool only_sparse_vars ) const {
181
+ platform::DeviceContext *dev_ctx, bool reset_all ) const {
183
182
for (auto &varname : recv_varnames) {
184
183
auto var = recv_scope->FindVar (varname);
185
184
if (var == nullptr ) {
186
185
VLOG (2 ) << " can not find var " << varname << " in received scope" ;
187
186
continue ;
188
187
}
189
188
if (var->IsType <framework::SelectedRows>()) {
189
+ VLOG (3 ) << " reset sparse var: " << varname;
190
190
var->GetMutable <framework::SelectedRows>()->mutable_rows ()->clear ();
191
191
}
192
- if (!only_sparse_vars) {
192
+ if (UNLIKELY (reset_all)) {
193
+ VLOG (3 ) << " reset dense var: " << varname;
193
194
if (var->IsType <framework::LoDTensor>()) {
194
195
math::set_constant (*dev_ctx, var->GetMutable <framework::LoDTensor>(),
195
196
static_cast <float >(0 ));
0 commit comments