Skip to content

Commit 139a892

Browse files
release GIL in constant folding pass
1 parent 7a7f5cb commit 139a892

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

paddle/fluid/pir/transforms/general/constant_folding_pass.cc

+8
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "paddle/pir/include/pattern_rewrite/frozen_rewrite_pattern_set.h"
5252
#include "paddle/pir/include/pattern_rewrite/pattern_match.h"
5353
#include "paddle/pir/include/pattern_rewrite/pattern_rewrite_driver.h"
54+
#include "pybind11/gil.h"
5455

5556
namespace {
5657

@@ -535,6 +536,13 @@ class ConstantFoldingPass : public pir::Pass {
535536
pir::GreedyRewriteConfig cfg;
536537
cfg.use_top_down_traversal = true;
537538
cfg.max_iterations = 10;
539+
540+
#if !defined(PADDLE_NO_PYTHON)
541+
if (PyGILState_Check()) {
542+
pybind11::gil_scoped_release release;
543+
}
544+
#endif
545+
538546
auto [_, num_rewrites] = pir::ApplyPatternsGreedily(op, patterns_, cfg);
539547
AddStatistics(num_rewrites, num_ops);
540548
}

0 commit comments

Comments
 (0)