[WIP] Code merge | Merge CINN into Paddle #54405
Closed
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
Breaking changes
PR changes
Others
Description
CINN编译器后续将作为Paddle训练推理的一个主要后端,出于以下几点考虑现将CINN合入Paddle repo:
CINN长久以来一直与Paddle分离研发,人力有限,在代码质量、规范检查等方面已与Paddle有较大差距,且cmake与thrid_party也存在诸多重复实现,因此两者整合很难一步到位,本PR仅做了最初级的整合工作,本PR合入后,后续剩余的整合与规范化工作可以适当并行开展加速
本PR当前工作
1. 将CINN主体代码按以下结构整合到Paddle中
2. 添加CINN_ONLY编译选项,按照以上目录结构编译通过,原单测可执行
将cinn根目录的CMakeLists.txt放置到Paddle/cmake/cinn.cmake中,原cinn的编译选项与Paddle编译选项有映射关系,不需要再单独保留,复用Paddle编译选项即可
单独编译CINN的编译:
cmake .. -DWITH_CINN=ON -DCINN_ONLY=ON -DWITH_GPU=ON -DWITH_TESTING=ON -DPY_VERSION=3.7
处于以下考虑保留CINN独立编译:
后续各组件的简要关系如下:

后续TODO
a. 逐个对比generic.cmake和cinn.cmake中的funciton,将cinn.cmake整合到generic.cmake
b. glog,gflags,gtest,mkldnn等基础组件要和单机整合
c. 移除Paddle原先ExternalProject_Add的cinn整合代码,改为dep动态链接库
d. WITH_CINN编译通过,联合的单测可以执行
e. Paddle+CINN联合编译:cmake .. -DWITH_CINN=ON -DWITH_GPU=ON -DWITH_TESTING=ON -DPY_VERSION=3.7
a. CINN的profiler可以复用Paddle的Profiler
b. CINN的报错检查可以复用PADDLE_ENFORCE
c. 涉及到动态库依赖关系梳理