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】Add equal function for IndexExpr #68987

Merged
merged 8 commits into from
Oct 29, 2024

Conversation

liuruyan
Copy link
Contributor

@liuruyan liuruyan commented Oct 27, 2024

PR Category

CINN

PR Types

New features

Description

  1. Remove MulAndNormalize func, because it has been integrated into Simplifymul.
  2. Add operator == func for IndexExpr, it will compare flatten form when meeting Add and Mul. e.g.
flatten form:
S0 + S1 + S2 ==> {S0, S1, S2}
S0 + S1 * 2 + S2 ==> {S0, S1 * 2, S2}
S0 + (S1 + 2) * 4 + S2 ==> {S0, (S1 + 2) * 4, S2}

equal func:
(S7 + S5) + (S4 + S6) === (S4 + S5) + (S6 + S7)
(S4 + S5) * 3 + (S6 / 2 + S7) * 2 === (S6 / 2 + S7) * 2 + (S4 + S5) * 3
(S4 + S5 * 2) * 3 + (S6 / 2 + S7) * 2 === (S6 / 2 + S7) * 2 + (S4 + S5 * 2) * 3
(S4 + S5 * 2) * 3 + (S6 / 2 + S7) * 2 + S4 === (S6 / 2 + S7) * 2 + (S4 + S5 * 2) * 3 + S4
  1. Rename IsCorrectPriority to comparePriority
  2. Rename CalculateExprComplexity to length, put it into IndexExpr class method.
  3. Add comment.

Pcard-67164

Copy link

paddle-bot bot commented Oct 27, 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.

@liuruyan liuruyan changed the title Equal IndexExpr 【CINN】Add equal function for IndexExpr Oct 28, 2024
@@ -1561,6 +1561,26 @@ int64_t IndexExpr::GetLargestMutiplyPart() const {
::common::errors::Unimplemented("Unsupported type of expr: %s", type()));
}

int32_t IndexExpr::length(int32_t count) const {
Copy link
Contributor

Choose a reason for hiding this comment

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

如果需要传入count的话,这个length作为IndexExpr的成员函数是不就不太合适了?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是的,下个PR将其移出。

@zyfncg zyfncg merged commit 738d26a into PaddlePaddle:develop Oct 29, 2024
28 checks passed
fxfxfxfxfxfxfxfx pushed a commit to fxfxfxfxfxfxfxfx/Paddle that referenced this pull request Oct 29, 2024
* equal IndexExpr

* add comment.

* fix bug

* Empty-Commit

* fix bug

* add equal in vector

* add unit test.
@liuruyan liuruyan deleted the equalIndexExpr branch October 29, 2024 06:11
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.

2 participants