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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
|
||
bool MatchAndRewrite(paddle::dialect::TransposeOp op, | ||
ir::PatternRewriter &rewriter) const override { | ||
auto prev_op = op->operand(0).source().GetDefiningOp(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现有IR写法太复杂了,需封装接口
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
确实,这个写法好像比较常见,我回头封装个接口吧
There was a problem hiding this comment.
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()是不是等价的?更推荐哪种写法呢?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
后面这些注释都用两个//吧,没看到有用///的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
文档生成一般用///描述class或函数的作用,后面可以考虑统一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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部分包括: