diff --git a/paddle/fluid/framework/lod_rank_table.cc b/paddle/fluid/framework/lod_rank_table.cc index 12536ec60b7f9aafe87661256b7bf6bb3869c2eb..6bc795b642bf79b7556869c5ebe9b0323d3cc5fc 100644 --- a/paddle/fluid/framework/lod_rank_table.cc +++ b/paddle/fluid/framework/lod_rank_table.cc @@ -19,10 +19,6 @@ namespace framework { void LoDRankTable::Reset(const LoD& lod, size_t level) { this->coarse_lod_.clear(); this->items_.clear(); - if (lod.size() == 0) { - // Reset to a empty rank table. - return; - } PADDLE_ENFORCE(level < lod.size(), "Cannot rank lod since the level %d is less than lod size %d", level, lod.size()); diff --git a/paddle/fluid/operators/controlflow/while_op.cc b/paddle/fluid/operators/controlflow/while_op.cc index 77fdcf41a7e3e8c208225ae868c06ebd0ab4eeae..0360cf5273591946570cac47e2578e43f498b550 100644 --- a/paddle/fluid/operators/controlflow/while_op.cc +++ b/paddle/fluid/operators/controlflow/while_op.cc @@ -58,7 +58,6 @@ class WhileOp : public framework::OperatorBase { void RunImpl(const framework::Scope &scope, const platform::Place &dev_place) const override { PADDLE_ENFORCE_NOT_NULL(scope.FindVar(Input(kCondition))); - auto &cond = scope.FindVar(Input(kCondition))->Get(); PADDLE_ENFORCE_EQ(cond.dims(), paddle::framework::make_ddim({1})); @@ -78,33 +77,13 @@ class WhileOp : public framework::OperatorBase { VLOG(2) << GetSkipEagerDeletionVarsDebugString(skip_vars); auto ctx = executor.Prepare(*program, block->ID(), skip_vars); - if (!is_test) { - while (cond.data()[0]) { - auto ¤t_scope = scope.NewScope(); - step_scopes->push_back(¤t_scope); - executor.RunPreparedContext(ctx.get(), ¤t_scope, false, true, - true); - } - } else { + while (cond.data()[0]) { auto ¤t_scope = scope.NewScope(); - executor.CreateVariables(*program, ¤t_scope, block->ID()); - while (cond.data()[0]) { - for (auto &name : current_scope.LocalVarNames()) { - auto *var = current_scope.Var(name); - framework::LoD empty_lod; - if (var->IsType()) { - // Clear all lod information for all lod_tensors. - auto *t = var->GetMutable(); - t->set_lod(empty_lod); - } else if (var->IsType()) { - auto *t = var->GetMutable(); - t->Reset(empty_lod, 0); - } - } - executor.RunPreparedContext(ctx.get(), ¤t_scope, false, false, - false); + step_scopes->push_back(¤t_scope); + executor.RunPreparedContext(ctx.get(), ¤t_scope, false, true, true); + if (is_test) { + scope.DeleteScope(¤t_scope); } - scope.DeleteScope(¤t_scope); } } };