Skip to content
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

Forbid control flow related ops to constant folding #62206

Merged

Conversation

yuanlehome
Copy link
Contributor

PR types

Bug fixes

PR changes

Others

Description

Pcard-71500
Forbid control flow related ops to constant folding.

Copy link

paddle-bot bot commented Feb 28, 2024

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@NeroLoh
Copy link
Contributor

NeroLoh commented Feb 28, 2024

LGTM

Copy link
Contributor

@zhoutianzi666 zhoutianzi666 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -78,7 +112,9 @@ void ConstantFoldingPass::ApplyImpl(ir::Graph *graph) const {
if (std::find(blacklist.begin(), blacklist.end(), op_node->Name()) !=
blacklist.end())
continue;

if (OutputUsedByControlFlow(op_node, cf_vars)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里显然只是想检测这个op_node的输出是否被控制流(while,condition_block)使用,我觉得可以在

image 这样是否也可以呢?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

也希望处理input var的情况,想象这么一种情况,控制流op与某个待折叠的op共享了一个权重输入,这时候还得在额外加一个for循环来处理,单个逻辑太分散,因此我就封装成了一个函数来调用

@yuanlehome yuanlehome merged commit 7d84d55 into PaddlePaddle:develop Feb 29, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants