-
Couldn't load subscription status.
- Fork 5.9k
CINN Add more Simplify scenario: Select2MinMax, BoundSimplify, PowerL… #74292
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
Conversation
| 你的PR提交成功,感谢你对开源项目的贡献! |
f603b19 to cff0dd2 Compare paddle/cinn/optim/ir_simplify.cc Outdated
| | ||
| using ir::ExprMutator<>::Visit; | ||
| | ||
| // 递归优化 Compare 操作数 |
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.
注释用 English
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
| } | ||
| }; | ||
| | ||
| struct SimplifySelect2MinMaxMutator : public ir::ExprMutator<> { |
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.
新增用例在这里
test/cpp/pir/cinn/ir_simplify_select_test.cc
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.
注释都加上啦
| } | ||
| }; | ||
| | ||
| struct SimplifyPowerCeilLog2BitOpLdexpfMutator : public ir::ExprMutator<> { |
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.
新增用例在这里
test/cpp/pir/cinn/ir_simplify_test.cc
| // 2. Match target pattern: pow(base, ceil(log2(x))) | ||
| if (op->name == "pow" && new_args.size() == 2) { | ||
| const Expr& base = new_args[0]; | ||
| const Expr& exponent = new_args[1]; |
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.
这类pow, 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.
5bf17f4 to 882e5c4 Compare | /re-run all-failed |
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.
- 由于历史包袱,Var Bound和CAS Bound区间定义暂时不统一,日后人力时间允许的话,需要统一定义
- 一些Comment可以下个PR补齐
- 需要关注下例行监控模型情况,是否存在新增报错、编译超时问题
paddle/cinn/optim/simplify_util.cc Outdated
| const ir::IndexExpr &expr, const common::SymbolicExprAnalyzer &ana) { | ||
| // Handle cases like `(a * C1 + b) / C2` and `(a * C1 + b) % C2` | ||
| // where `C1` and `C2` are constants |
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
paddle/cinn/optim/simplify_util.cc Outdated
| if (rhs.is_constant() && rhs.as_int64() == denom_val) { | ||
| // Extract terms divisible by denominator | ||
| multiple_terms.push_back(term.operand(0)); // Extract multiplicand part |
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 (rhs.is_constant() && rhs.as_int64() == denom_val) { | |
| // Extract terms divisible by denominator | |
| multiple_terms.push_back(term.operand(0)); // Extract multiplicand part | |
| if (rhs.is_constant() && rhs.as_int64() % denom_val == 0) { | |
| // Extract terms divisible by denominator | |
| multiple_terms.push_back(term.operand(0) * (rhs.as_int64() / denom_va)); // Extract multiplicand part |
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
882e5c4 to d4a4336 Compare | /re-run all-failed |
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 Category
CINN
PR Types
New features
Description
DeepSeek子网涉及到的一些Simplify优化:
SelectOp -> Min Max
BoundSimplify优化:支持 (ax + b)/a, a > b --> x, (ax + b)% a, a > b --> b,
“Power+Log”优化成“Bit操作+ldexpf"
明确CINN中UpperBound能否取到,修正UpperBound的传递关系,使其计算更准确
Var [LowerBound, UpperBound)左闭右开,
For loop_var [LowerBound, UpperBound)左闭右开,
CasInterval [LowerBound, UpperBound]左闭右闭,
SymbolicExprAnalyzer [LowerBound, UpperBound]左闭右闭
Pcard-90680