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