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

[IR&PASS] part 3-3: Add PatternRewrite Driver code. #54738

Merged
merged 23 commits into from Jun 27, 2023

Conversation

jiweibo
Copy link
Contributor

@jiweibo jiweibo commented Jun 19, 2023

PR types

Others

PR changes

Others

Description

Pcard-71500

新IR下的新PASS体系,新PASS体系适配新IR。该系列PR主要包括如下几个部分:
主要包括四个部分:(1) Pass base & PassManager & PassAdaptor; #54023 (2) AnalysisManager & Pass Instrumentation (PassTiming, IRPrinting..); #54170 #54308 #54348 (3) Pattern Rewrite ... #54385 #54492 (4) 其他。

本PR完成第3部分包括:

  • Add PatternRewrite Driver code.
  • 待IR全量支持mutation操作后,补全RewriterBase,并更新单测

@paddle-bot
Copy link

paddle-bot bot commented Jun 19, 2023

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

@jiweibo jiweibo changed the title [IR&PASS] part 3-2: Add PatternRewrite Driver code. [IR&PASS] part 3-3: Add PatternRewrite Driver code. Jun 19, 2023
paddle/ir/core/region.cc Outdated Show resolved Hide resolved

bool MatchAndRewrite(paddle::dialect::TransposeOp op,
ir::PatternRewriter &rewriter) const override {
auto prev_op = op->operand(0).source().GetDefiningOp();
Copy link
Contributor Author

@jiweibo jiweibo Jun 25, 2023

Choose a reason for hiding this comment

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

现有IR写法太复杂了,需封装接口

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
Contributor

Choose a reason for hiding this comment

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

op->operand(0)和op.x()是不是等价的?更推荐哪种写法呢?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

C++写法 op.x()可以,生成的话一般是operand(0)

Copy link
Contributor

Choose a reason for hiding this comment

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

x对应的是算子的输入的名字,是跟具体算子类型相关的。operand(0)对应的是输入的index,是通用接口。

auto new_perm = GetPerm(axis_first, axis_last);
rewriter.SetInsertionPoint(op);
auto new_op = rewriter.Build<paddle::dialect::TransposeOp>(
prev_op->operand(0).source().GetDefiningOp()->result(0), new_perm);
Copy link
Contributor Author

@jiweibo jiweibo Jun 25, 2023

Choose a reason for hiding this comment

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

写法复杂,需封装接口


namespace ir {

/// This enum will control which ops will be added to the worklist during the
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
Contributor Author

Choose a reason for hiding this comment

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

文档生成一般用///描述class或函数的作用,后面可以考虑统一下

@jiweibo jiweibo requested a review from winter-wang June 26, 2023 03:10
winter-wang
winter-wang previously approved these changes Jun 26, 2023
Copy link
Contributor

@winter-wang winter-wang left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@winter-wang winter-wang left a comment

Choose a reason for hiding this comment

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

LGTM

@jiweibo jiweibo merged commit 72b8c7c into PaddlePaddle:develop Jun 27, 2023
23 of 26 checks passed
@jiweibo jiweibo deleted the pass_sim branch June 27, 2023 02:33
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.

None yet

3 participants