未验证 提交 fcb67605 编写于 作者: Z zhangbo9674 提交者: GitHub

[IR] Add control flag for ir inplace pass (#57090)

* add control flag

* add log
上级 40431e66
......@@ -23,6 +23,9 @@
#include "paddle/ir/core/value.h"
#include "paddle/ir/pass/pass.h"
#include "paddle/ir/pass/pass_manager.h"
#include "paddle/phi/core/flags.h"
PHI_DECLARE_bool(new_ir_apply_inplace_pass);
namespace paddle {
namespace framework {
......@@ -444,9 +447,11 @@ std::unique_ptr<::ir::Program> ConstructFowardIrProgram(
auto ir_res = paddle::dialect::PdOpLowerToKernelPass(program.get());
if (FLAGS_new_ir_apply_inplace_pass) {
::ir::PassManager pm(::ir::IrContext::Instance(), 3);
pm.AddPass(::ir::CreateInplacePass());
pm.Run(ir_res.get());
}
return ir_res;
}
......@@ -521,9 +526,11 @@ std::unique_ptr<::ir::Program> ConstructBackwardIrProgram(
auto res = paddle::dialect::PdOpLowerToKernelPass(program.get());
if (FLAGS_new_ir_apply_inplace_pass) {
::ir::PassManager pm(::ir::IrContext::Instance(), 3);
pm.AddPass(::ir::CreateInplacePass());
pm.Run(res.get());
}
return res;
}
......
......@@ -330,6 +330,8 @@ class InplacePass : public ir::Pass {
"is_inplace",
ir::BoolAttribute::get(ir::IrContext::Instance(), true));
}
LOG_FIRST_N(INFO, 1)
<< "Apply inplace pass on lowering ::ir::Program to Kernel Dialect.";
}
bool CanApplyOn(ir::Operation* op) const override {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册