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

【prim】uniform Decomp list #70204

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

xiaoguoguo626807
Copy link
Contributor

@xiaoguoguo626807 xiaoguoguo626807 commented Dec 13, 2024

PR Category

Execute Infrastructure

PR Types

Improvements

Description

pcard-67164

整理组合算子生成名单。
paddle/fluid/pir/dialect/op_generator/decomp_interface_gen_op_list.py 中的名单作用:
decomp_interface_gen_op_list.py 中包含两组名单,一组前向拆解声明+实现; 一组反向拆解声明+实现
decomp_rule_xxx_list 是控制前向decomp接口生成,decomp_vjp_xxx_list 是控制反向decomp接口生成,

声明list 引用逻辑:
paddle/fluid/pir/dialect/op_generator/op_gen.py 中引用decomp_rule_declare_list, decomp_vjp_declare_list, 分别负责生成decomp, decomp_vjp 接口的声明,以及对应的Interface ,生成位置在pd_op.h中。

实现list 引用逻辑:
paddle/fluid/primitive/codegen/decomp_rule_gen.py 引用decomp_rule_implementation_list负责生成decomp接口的实现, 被,生成代码位置在op_decomp_rule.cc;
paddle/fluid/primitive/codegen/decomp_vjp_gen.py decomp_vjp_implementation_list负责生成decomp_vjp 接口的实现,生成代码位置在op_decomp_vjp.cc;

声明的list = generate实现list + manual实现list 因此按照此逻辑进行重构。

paddle/fluid/primitive/codegen/decomp_vjp_gen.py 中还有一组反向op list,
按照prim_vjp和custom_vjp 构成vjp总list,

custom_vjp 被paddle/fluid/pir/dialect/op_generator/op_gen.py引用,负责生成custom_trait 用于op 进行has_custom_vjp 的判断。

vjp 总list 用来生成generated_vjp.h/ generated_vjp.cc 在相应的vjp 逻辑中生成decomp_vjp 的调用链路。

由于两组名单用于生成的内容不同,分流方式也不同,因此需要两套名单。同时两个列表的总vjp list 也可能不全。decomp_interface中总名单会缺少manual_op.h 中定义的op;
vjp_gen中总名单会缺少manual_vjp.h中和manual_op.h中的op.

Copy link

paddle-bot bot commented Dec 13, 2024

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

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.

2 participants