[AP] Add paddle.cc.ap.FacadeOp: a custom op machanism for ap pass only#72525
Merged
Conversation
…interpret_cast to avoid strict-aliasing.
…atement added by previous commit.
Fix the mismatched output numerical order issue
|
你的PR提交成功,感谢你对开源项目的贡献! |
Codecov ReportAttention: Patch coverage is
❌ Your patch status has failed because the patch coverage (30.23%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #72525 +/- ##
==========================================
Coverage ? 30.23%
==========================================
Files ? 9
Lines ? 506
Branches ? 0
==========================================
Hits ? 153
Misses ? 353
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
zhangbo9674
approved these changes
May 8, 2025
zyfncg
approved these changes
May 8, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Category
CINN
PR Types
New features
Description
pcard-76996
动机
当我们将用户的custom op升级成apass时,要求现在pir/phi系统里引入该custom op。用户不得不重新编译paddle代码,这就和ap的理念不符,且拖慢开发速度。
为此,我们设计了通用的
pd_op.ap_facade和ap_op.facade两个op,前者用于python层配置,后者用于drr pass匹配。实际上,用户用paddle.cc.ap.FacadeOp机制能更便利地添加新扩展算子。使用示例
一个能跑通的示例,lixinqi/Athena#37 :
python
axpr
从代码中可以看出,TupleIdentityOp需要axpr代码文件tuple_identity_util.py的infer_meta和infer_symbolic函数。
运行方法
之后我们会在输出日志里看到如下日志(可能不是位于末尾):
从日志中可以看出,pd_op.ap_facade前后总是伴随builtin.combine和builtin.split,这是因为它的输入输出是tensor list。显然ap_op.facade比它更容易在drr_pass内用起来。
注意看,上述日志中ap_op.facade算子的
custom_op_name的值为"ap_custom_op.tuple_identity",此字段在drr pass的用法为:infer_meta 相关接口
输入的MetaTensor
输出的MetaTensor
infer_symbolic 相关接口
pir::InferSymbolicShapeContext*symbol::ShapeOrDataDimExprs其中的match用法类似axpr python里的pir attribute
ShapeOrDataDimExprs具体alternative对象的构造统一用
pir模块进行symbol::DimExpr