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

[PTen] Add cmake function for kernels #38311

Merged
merged 10 commits into from
Dec 22, 2021

Conversation

chenwhql
Copy link
Contributor

@chenwhql chenwhql commented Dec 21, 2021

PR types

Function optimization

PR changes

Others

Describe

[PTen] Add cmake function for kernels

添加cmake函数register_kernels,类似原先的register_operators,扫描目录下所有kernel实现,根据文件名创建编译target,同时解析kernel注册代码,在公共头文件中添加kernel符号导出的声明,要求kernel按如下形式组织:

  • pten/kernels根目录下放置包含kernel函数声明的头文件,命名格式为***_kernel.h,有其他kernel复用当前kernel时,需在相应.cc/cu中include复用kernel的头文件
  • 各设备的kernel实现,均在对应的设备文件夹下,除了文件后缀,命名与头文件严格一致,例如cpu/***_kernel.cc

此PR合入后,无特殊情况,不需要额外添加cmake条目与kernel declare声明,暂时如果依赖关系比较特殊的话,还需要手动声明一下,例如

kernel_library(flatten_kernel DEPS ${FLATTEN_DEPS})

TODO:自动根据头文件include关系,自动生成kernel复用时的编译依赖关系

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

# See the License for the specific language governing permissions and
# limitations under the License.

# call kernel_declare need to make sure the target of input is exists
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

后续pr 中可以删除注释中的 is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thx

@chenwhql chenwhql merged commit e6310db into PaddlePaddle:develop Dec 22, 2021
zmxdream pushed a commit to zmxdream/Paddle that referenced this pull request Dec 25, 2021
* add pten kernel cmake

* add pten kernel cmake function

* fix compile error

* add enforce include for full kernel

* fix compile failed

* change cuda to gpu

* fix cmake function error
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.

3 participants