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

[CINN] optimize symbol shape dim expr substitute in lower_cinn_fusion… #62951

Merged
merged 1 commit into from
Apr 3, 2024

Conversation

ZelinMa557
Copy link
Contributor

@ZelinMa557 ZelinMa557 commented Mar 22, 2024

PR Category

CINN

PR Types

Devs

Description

  1. 更新原cinn lower_cinn_fusion_op_pass中对符号shape expr做替换的流程,原流程为 a) 获取所有输入value中包含的复合表达式,分别赋新值 b)对group中所有value做替换。现更改为仅对输入value的shape做替换,其余value重新推导shape
  2. 在做替换时,尽可能保持原有的约束关系,如果输入value的shape包含[s0, s1, Add(s0, s0, s1), Add(s0, s2)], 其中Add(s0, s0, s1)不再被替换,Add(s0, s2)将被整体替换成新的符号

Copy link

paddle-bot bot commented Mar 22, 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.

@paddle-bot paddle-bot bot added the contributor External developers label Mar 22, 2024
Copy link

paddle-bot bot commented Mar 22, 2024

❌ The PR is not created using PR's template. You can refer to this Demo.
Please use PR's template, it helps save our maintainers' time so that more developers get helped.

const std::unordered_set<symbol::DimExpr>& exprs) {
auto judge_unary =
[&](const symbol::DimExpr& data_of_expr) {
if (data_of_expr.isa<std::int64_t>()) return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

对于像S3这样单个的符号可以不做替换,在一些情况下就不需要对Group重新推导符号了。

Comment on lines 872 to 815
while (!zero_indegree_ops.empty()) {
auto op = zero_indegree_ops.front();
InferSymbolicShapeForOperation(op, local_shape_analysis);
Copy link
Contributor

Choose a reason for hiding this comment

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

group内里的 op list 满足拓扑序,可以直接遍历调用

@ZelinMa557 ZelinMa557 force-pushed the symbolic-infer-dev branch 8 times, most recently from 8111b7e to 8f9b791 Compare April 1, 2024 12:27
@ZelinMa557 ZelinMa557 force-pushed the symbolic-infer-dev branch from 8f9b791 to fcd2274 Compare April 1, 2024 12:32
@zyfncg zyfncg merged commit 620880a into PaddlePaddle:develop Apr 3, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants