Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kangguangli committed Apr 8, 2023
1 parent 3f96a97 commit cb1c23d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
5 changes: 2 additions & 3 deletions paddle/fluid/framework/details/build_strategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ struct BuildStrategy {
bool fuse_adamw_{false};
// Fused feed forward
bool fused_feedforward_{false};
bool force_sequential_run_{false};
bool sequential_run_{false};

// mkldnn_enabled_op_types specify the operator type list to
// use MKLDNN acceleration. It is null in default, means
Expand Down Expand Up @@ -270,8 +270,7 @@ inline std::ostream &operator<<(std::ostream &os,
os << "fuse_gemm_epilogue_: " << strategy.fuse_gemm_epilogue_ << std::endl;
os << "fused_attention_: " << strategy.fused_attention_ << std::endl;
os << "fused_feedforward_: " << strategy.fused_feedforward_ << std::endl;
os << "force_sequential_run_: " << strategy.force_sequential_run_
<< std::endl;
os << "sequential_run_: " << strategy.sequential_run_ << std::endl;
os << "mkldnn_enabled_op_types_: ";
for (auto str : strategy.mkldnn_enabled_op_types_) {
os << str << ", ";
Expand Down
8 changes: 4 additions & 4 deletions paddle/fluid/operators/controlflow/conditional_block_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class ConditionalBlockOp : public ConditionalOp {

core_.reset(new InterpreterCore(
dev_place, *block, &cur_scope, execution_config));
VLOG(10) << "[interpreterCore cache]"
<< "new created:" << core_;
VLOG(10) << "[interpreterCore]"
<< "created:" << core_;
} else {
BuildScopeForControlFlowOp(*core_, *block, &cur_scope);
core_->reset_scope(&cur_scope);
Expand Down Expand Up @@ -204,8 +204,8 @@ class ConditionalBlockGradOp : public ConditionalOp {

core_.reset(new InterpreterCore(
dev_place, *block, &cur_scope, execution_config));
VLOG(10) << "[interpreterCore cache]"
<< "new created:" << core_;
VLOG(10) << "[interpreterCore]"
<< "created:" << core_;
} else {
BuildScopeForControlFlowOp(*core_, *block, &cur_scope);
core_->reset_scope(&cur_scope);
Expand Down
10 changes: 5 additions & 5 deletions paddle/fluid/pybind/parallel_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -760,17 +760,17 @@ void BindParallelExecutor(pybind11::module &m) { // NOLINT
build_strategy.fused_feedforward = True
)DOC")
.def_property(
"force_sequential_run",
[](const BuildStrategy &self) { return self.force_sequential_run_; },
"sequential_run",
[](const BuildStrategy &self) { return self.sequential_run_; },
[](BuildStrategy &self, bool b) {
PADDLE_ENFORCE_NE(self.IsFinalized(),
true,
platform::errors::PreconditionNotMet(
"BuildStrategy has been finlaized, cannot be "
"configured again."));
self.force_sequential_run_ = b;
self.sequential_run_ = b;
},
R"DOC((bool, optional): force_sequential_run is used to let the `StandaloneExecutor` run ops by the
R"DOC((bool, optional): sequential_run is used to let the `StandaloneExecutor` run ops by the
order of `ProgramDesc`. Default is False.
Examples:
Expand All @@ -782,7 +782,7 @@ void BindParallelExecutor(pybind11::module &m) { // NOLINT
paddle.enable_static()
build_strategy = static.BuildStrategy()
build_strategy.fused_feedforward = True
build_strategy.sequential_run = True
)DOC")
.def_property(
"fuse_bn_act_ops",
Expand Down
5 changes: 1 addition & 4 deletions python/paddle/fluid/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1599,10 +1599,7 @@ def _can_use_interpreter_core(program, place):
else program._graph
)
build_strategy = compiled_program._build_strategy
if (
build_strategy is not None
and build_strategy.force_sequential_run
):
if build_strategy is not None and build_strategy.sequential_run:
schedule_flag = [
'FLAGS_new_executor_serial_run',
'FLAGS_new_executor_sequential_run',
Expand Down
4 changes: 2 additions & 2 deletions test/standalone_executor/test_standalone_sequentail_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ def build_program(self):

return main_program, startup_program, [c]

def run_program(self, force_sequential_run=False):
def run_program(self, sequential_run=False):
seed = 100
paddle.seed(seed)
np.random.seed(seed)
main, startup, outs = self.build_program()
build_strategy = paddle.static.BuildStrategy()
build_strategy.force_sequential_run = force_sequential_run
build_strategy.sequential_run = sequential_run
print(build_strategy)
compiled_program = paddle.static.CompiledProgram(
main, build_strategy=build_strategy
Expand Down

0 comments on commit cb1c23d

Please sign in to comment.