-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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 pass to fold consecutive IfThenElse. #70142
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
paddle/cinn/optim/if_fold_pass.cc
Outdated
return true; | ||
} | ||
|
||
bool IsInnerIfWithEqCond(const StmtRef& stmt) { |
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.
为什么叫InnerIf?函数实现看上去和inner没有多少关联?
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.
函数内部确实没有判断是否为 inner, 只是调用处限制了 inner,命名存在不妥之处,已修改
ir::IndexExpr expr(0); | ||
int32_t min_len = INT32_MAX; | ||
|
||
VLOG(6) << "-------------cond_vec start--------------"; |
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.
这是调试log吗?
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.
是预留的调试信息,之后方便调试
if (eq_lhs.is_index()) | ||
cond_vec->push_back(common::ChangeSeqOfDivMod( | ||
ir::ir_utils::IRCopy(eq_lhs).as_index().Normalize())); |
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.
if加{}
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.
Done
if (v.node_type() == ir::IrNodeTy::Div) { | ||
expr = expr + v * v.operand(1); | ||
} else { | ||
expr = expr + v; | ||
} |
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.
Done
PR Category
CINN
PR Types
Performance
Description
div
andmod
sequence inIndexExpr
IfThenElse
stmts if their conditions can be simplified. For example:Pcard-67164