Skip to content

[CINN] Add inplace ops order check in build_cinn_pass #72037

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

Conversation

huangjiyi
Copy link
Member

@huangjiyi huangjiyi commented Apr 2, 2025

PR Category

CINN

PR Types

Bug fixes

Description

Pcard-76996

  • Add inplace ops order check in build_cinn_pass

Copy link

paddle-bot bot commented Apr 2, 2025

你的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.

Comment on lines 642 to 649
for (const auto& shared_value : shared_inplace_values) {
inplace_ops_order_.emplace_back();
for (size_t i = 0; i < inplace_values_sets.size(); ++i) {
if (inplace_values_sets[i].count(shared_value)) {
inplace_ops_order_.back().push_back(inplace_ops[i]);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

这里看起来只考虑了input value的情况,如果是 b = op_(a), c = op_(b)的情况可以处理吗?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

可以再加个单测检查下

Copy link
Member Author

Choose a reason for hiding this comment

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

这个目前没办法写出因为 group 合并导致 inplace 顺序改变的 PR,本地测了包含几个 inplace 的 case 测试代码都没问题

@SigureMo SigureMo requested a review from Copilot April 7, 2025 18:47
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

paddle/fluid/pir/transforms/sub_graph_detector.cc:597

  • [nitpick] The lambda get_inplace_root_value stops iterating upon detecting a cycle by breaking the loop. It may improve clarity and maintainability to add a comment explaining the cycle detection and its intended handling.
while (inplace_map.count(root)) {

@huangjiyi huangjiyi merged commit 630ff47 into PaddlePaddle:develop Apr 11, 2025
32 checks passed
YqGe585 pushed a commit to YqGe585/Paddle that referenced this pull request May 7, 2025
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