CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[IR] Support inplace pass #56672
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
[IR] Support inplace pass #56672
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
✅ This PR's description meets the template requirements! |
… dev/add_inplace_pass_for_ir
… dev/add_inplace_pass_for_ir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for set_tests_properties(test_pd_inplace_pass PROPERTIES TIMEOUT 60)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for file changes in standalone_executor.cc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall
@@ -16,16 +16,24 @@ | |||
#include "paddle/fluid/framework/new_executor/feed_fetch_utils.h" | |||
#include "paddle/fluid/framework/new_executor/interpreter/interpreter_util.h" | |||
#include "paddle/fluid/framework/new_executor/program_interpreter.h" | |||
#include "paddle/fluid/platform/flags.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议使用phi下的flags,一般更安全些
|
||
PHI_DECLARE_bool(enable_new_ir_in_executor); | ||
PHI_DECLARE_bool(enable_new_ir_api); | ||
|
||
PADDLE_DEFINE_EXPORTED_bool(new_ir_apply_inplace_pass, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里也建议放到phi/flags.cc里
|
||
PHI_DECLARE_bool(enable_new_ir_in_executor); | ||
PHI_DECLARE_bool(enable_new_ir_api); | ||
|
||
PADDLE_DEFINE_EXPORTED_bool(new_ir_apply_inplace_pass, | ||
true, | ||
"new ir kernel program apply inplace pass."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"new ir kernel program apply inplace pass."); | |
"Whether to apply inplace pass on lowering ::ir::Program to Kernel Dialect."); |
del_value_2_op[input] = op; | ||
} | ||
|
||
for (size_t i = 0; i < op->num_results(); ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Operation 里已支持了 results() 和 oprands() 接口。
visited_values.insert(op->operand_source(i)); | ||
} | ||
|
||
if (op->dialect()->name().compare( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里似乎很多地方都会用到?可以抽成一个 is_kenel_dialect_op ?
// NOTE(zhangbo): Which kind of value can be deleted? | ||
// (1) Value's type needs to be AllocatedDenseTensorType or | ||
// AllocatedSelectedRowsType; (2) Value's is not persisable. | ||
bool CanBeDeleted(ir::Value value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一般对于这种某个类的辅助函数,我们会把他们统一放到类似 details namspace里,并用static 标记为「仅当前编译单元可见」。
@@ -759,6 +759,10 @@ def relu(x, name=None): | |||
if in_dynamic_mode(): | |||
return _C_ops.relu(x) | |||
else: | |||
if paddle.ir.core._use_new_ir_api(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#56809 这个PR 合入后,这里可以改为:if in_dynamic_or_new_ir_mode():
* add code * add code * refine code * add code * fix bug * fix bug * fix bug * add code * add ut * polish code * fix bug * refine code * fix bug * refine code * fix bug * refine code * fix bug * refine code * fix bug * refine code * add code * fix bug * fix bug * fix bug * fix bug * fix bug * refine code
PR types
New features
PR changes
Others
Description
为新 IR kernekl_dialect 添加 inplace pass,在 program lower 到 kernel_dialect 之后,添加该 pass。当前可以通过 FLAGS_new_ir_apply_inplace_pass 控制是否应用该 pass,默认打开
Other
Pcard-67164