Skip to content

Commit 0594d2a

Browse files
authored
Revert "refine case when thread_num = 1 (#36201)" (#36347)
This reverts commit 7e60cc6.
1 parent 2a75b44 commit 0594d2a

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.cc

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,7 @@ FastThreadedSSAGraphExecutor::FastThreadedSSAGraphExecutor(
4747
<< "Change thread number to 1 because the toposort order is unique";
4848
strategy_.num_threads_ = 1;
4949
}
50-
if (strategy_.num_threads_ > 1) {
51-
pool_.reset(new ::ThreadPool(strategy.num_threads_));
52-
} else {
53-
auto nodes = ir::TopologySortOperations(*graph_);
54-
traced_ops_.clear();
55-
traced_ops_.reserve(nodes.size());
56-
for (auto *node : nodes) {
57-
traced_ops_.push_back(&node->Wrapper<OpHandleBase>());
58-
}
59-
}
50+
pool_.reset(new ::ThreadPool(strategy.num_threads_));
6051
for (auto &op : ir::FilterByNodeWrapper<OpHandleBase>(*graph_)) {
6152
int dep = static_cast<int>(op->NotReadyInputSize());
6253
op_deps_.emplace(op, dep);
@@ -239,7 +230,7 @@ void FastThreadedSSAGraphExecutor::RunOpAsync(
239230
OpHandleBase *op,
240231
const std::shared_ptr<BlockingQueue<size_t>> &complete_q) {
241232
++remaining_;
242-
auto func = [=] {
233+
this->pool_->enqueue([=] {
243234
std::deque<OpHandleBase *> op_queue;
244235
op_queue.push_front(op);
245236

@@ -298,12 +289,7 @@ void FastThreadedSSAGraphExecutor::RunOpAsync(
298289
}
299290
--remaining_;
300291
complete_q->Push(complete);
301-
};
302-
if (pool_) {
303-
pool_->enqueue(func);
304-
} else {
305-
func();
306-
}
292+
});
307293
}
308294

309295
void FastThreadedSSAGraphExecutor::PrepareAtomicOpDeps() {

0 commit comments

Comments
 (0)