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] Refine Kernel Registrar Writing #37977

Merged

Conversation

chenwhql
Copy link
Contributor

@chenwhql chenwhql commented Dec 8, 2021

PR types

Function optimization

PR changes

Others

Describe

[PTen] Refine Kernel Registrar Writing

  • 经过调研与讨论,我们内部kernel的overload情况很多,想要用简单的枚举规范化比较困难,因此overload_name基本属于过度设计了,后续会简化这里的设计,需要overload name的场景仍然直接使用下划连接相应字符串后缀实现,具体的命名根据实际情况决定,表意准确即可
  • 此外,.overload_name机制去除的话,kernel注册写法改回和原fluid注册一致的写法,即直接使用名字,而不是字符串,在编译自动化上更易实现,因此进行了全局修改

@paddle-bot-old
Copy link

paddle-bot-old bot commented Dec 8, 2021

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

* of the kernel, this registration macro will not do automatic template
* instantiation.
*/
#define PT_REGISTER_SINGLE_KERNEL( \
Copy link
Contributor

Choose a reason for hiding this comment

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

PT_REGISTER_SINGLE_KERNEL是不是没有使用?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是的,但是我们需要保留这样一个基础接口,这个是使用一个函数指针进行标准注册的情况,在无法使用PT_REGISTER_KERNEL注册的时候,即使重复写很多遍,也要能注册一个kernel

@@ -130,12 +130,9 @@ void Cast(const CPUContext& dev_ctx,

} // namespace pten

// TODO(chenweihang): replace by better impl
PT_REGISTER_MODULE(ManipulationCPU);

// TODO(yuanrisheng): "flatten_contiguous_range" is compatible with old kernel
// architecture, kernel_name should be "flatten".
Copy link
Contributor

Choose a reason for hiding this comment

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

这个todo可以删掉了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thx,下一个PR移除

@chenwhql chenwhql merged commit b199ba8 into PaddlePaddle:develop Dec 9, 2021
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.

4 participants