-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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】C++ API Code-Generation #37668
Conversation
Thanks for your contribution! |
|
||
|
||
def license(): | ||
return """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
编译期间生成的文件,license 不用添加
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM,先有初版,细节设计后续可以按需迭代完善
output : Tensor | ||
invoke : full_like(x, 0, dtype, place, layout) | ||
|
||
# - api : full_like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果是非必要的注释,建议后续PR移除
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里想的是放一个不同的API定义格式用来对比和进行讨论,后续PR中会删除
* add code-gen file * add api-gen in cmake * adjust the code format * temp save the code * add genen-api module into pten * merge the develop code * fix merge conflict * fix code conflict with develop * support reduce_mean/sum * fix the CI requirement * fix requirement problem of CI * remove original api code * fix bug caused by removing original api
PR types
Breaking changes
PR changes
APIs
Describe
目标:通过文件配置完成PTen中C++ API的代码自动生成,减少C++ API的开发成本
方案概览:使用yaml文件进行C++ API代码的生成配置(主要包括API的接口命名、输入输出参数、使用的InferMeta函数、调用的计算kernel以及kernel的选择配置等),在程序构建时会读取yaml配置文件进行解析并生成对应的C++ API代码(包括声明API的头文件和API实现逻辑的源文件)。
API配置文件格式:
以matmul和 full_like为例:
生成API代码示例(matmul):
从整体效果看,使用API自动生成将原来需要手动编写的几十行API代码简化为10行左右的配置文件,可以有效降低C++ API的开发成本