[CINN Frontend] Optimize user interface, polish fuse_pass classes #55705
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 types
Function optimization
PR changes
Others
Description
Pcard-73448
背景与意义
Fusion pass 的初步改造已经完成,然而仍有部分遗留 TODO 待解决,例如 pass 的所有逻辑都写在了文件中:
paddle/cinn/hlir/pass/general_fusion_merge_pass.cc
。会造成多个问题:因此,迫切需要对该文件进行拆分,本 PR 将 pass 中的每个类都拆分成单独的文件,放到了单独的
general_fusion_merge_pass
文件夹内统一管理,每个类对应一个同名的.h
文件,便于后续维护,类继承结构如下图所示:新增融合策略
用户新增融合策略时,只需要参考
general_fusion_merge_pass
文件夹中的.cc
文件,完成三处定义,即可为 fusion_merge pass 新增一个融合策略,例如default_horizontal_fuse_pass.cc
中定义的融合策略如下:Background and meaning
The initial version of the fusion pass has been completed, but some legacy TODOs are still unresolved. For example, all the pass logic is written in the file:
paddle/cinn/hlir/pass/general_fusion_merge_pass.cc
. This may cause multiple problems:Therefore, it is urgent to split the file. This PR splits each class in the pass into a separate file and puts it in a separate
general_fusion_merge_pass
folder for unified management. Each class corresponds to a. h
file, which is convenient for subsequent maintenance. The class inheritance structure is shown in the figure above.Add fusion strategy
When users add a fusion strategy, they only need to refer to the
.cc
file in thegeneral_fusion_merge_pass
folder and complete the three definitions to add a fusion strategy for the fusion_merge pass, such as the fusion strategy defined indefault_horizontal_fuse_pass.cc
as above.