[PTen] Add cmake function for kernels #38311
Merged
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
Describe
[PTen] Add cmake function for kernels
添加cmake函数register_kernels,类似原先的register_operators,扫描目录下所有kernel实现,根据文件名创建编译target,同时解析kernel注册代码,在公共头文件中添加kernel符号导出的声明,要求kernel按如下形式组织:
***_kernel.h,有其他kernel复用当前kernel时,需在相应.cc/cu中include复用kernel的头文件cpu/***_kernel.cc此PR合入后,无特殊情况,不需要额外添加cmake条目与kernel declare声明,暂时如果依赖关系比较特殊的话,还需要手动声明一下,例如
kernel_library(flatten_kernel DEPS ${FLATTEN_DEPS})TODO:自动根据头文件include关系,自动生成kernel复用时的编译依赖关系