Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix][ConditionalBlock] fix judgement about scope validation #50086

Merged
13 changes: 2 additions & 11 deletions paddle/fluid/operators/controlflow/conditional_block_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,8 @@ class ConditionalBlockOp : public ConditionalOp {
"got a null Scope variable. Please set the Scope variable."));

auto *scopes = scope_var->GetMutable<std::vector<framework::Scope *>>();

if (scopes->size() == 0 || !FLAGS_control_flow_use_new_executor) {
scopes->resize(1);
scopes->front() = &scope.NewScope();
}

// We need to know whether the scope we cached is still valid.
// If not, we need to create a new one.
if (scope.kids().size() == 0) {
scopes->front() = &scope.NewScope();
}
scopes->resize(1);
scopes->front() = &scope.NewScope();

auto &cur_scope = *scopes->front();
#ifdef PADDLE_WITH_MKLDNN
Expand Down