-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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 alias kernel name #37881
[PTen]Add alias kernel name #37881
Conversation
Thanks for your contribution! |
paddle/pten/core/convert_utils.cc
Outdated
@@ -20,6 +20,26 @@ limitations under the License. */ | |||
|
|||
namespace pten { | |||
|
|||
// the map between kernel name in fluid and pten |
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.
这里再加些注释,说明一下key,value 是什么含义吧
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
paddle/pten/core/convert_utils.cc
Outdated
{"reshape2", "reshape"}, | ||
{"fill_any_like", "full_like"}, | ||
{"fill_constant", "full"}, | ||
{"matmul_v2", "matmul"}, | ||
{"flatten_contiguous_range", "flatten"}, | ||
{"reduce_mean", "mean"}, | ||
{"reduce_sum", "sum"}, | ||
{"elementwise_add", "add"}, | ||
{"elementwise_sub", "subtract"}, | ||
{"elementwise_mul", "muliply"}, | ||
{"elementwise_div", "divide"}, |
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.
这里是不可以按照一个统一的规则排下序,后面迁移的kernel多了找起来也方便
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
paddle/pten/core/convert_utils.cc
Outdated
@@ -304,4 +324,12 @@ int TensorDtype2NumpyDtype(pten::DataType dtype) { | |||
} | |||
} | |||
|
|||
std::string TransToPtenKernelName(const std::string& fluid_op_name) { |
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.
可以返回const std::string&
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
paddle/pten/core/convert_utils.h
Outdated
@@ -32,6 +32,8 @@ namespace pten { | |||
using DataType = paddle::experimental::DataType; | |||
using DataLayout = paddle::experimental::DataLayout; | |||
|
|||
std::string TransToPtenKernelName(const std::string& fluid_op_name); |
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.
同上
@@ -101,10 +101,10 @@ KernelSignatureMap& KernelSignatureMap::Instance() { | |||
if (pten::KernelFactory::Instance().HasCompatiblePtenKernel(op_type)) { | |||
KernelArgsNameMakerByOpProto maker(op_proto); | |||
VLOG(10) << "Register kernel signature for " << op_type; |
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.
这里的op_type 是不是也要pten::TransToPtenKernelName(op_type)
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.
不需要
@@ -63,7 +63,7 @@ void FillConstant(const CPUContext& dev_ctx, | |||
|
|||
PT_REGISTER_MODULE(CreationCPU); | |||
|
|||
PT_REGISTER_KERNEL("fill_any_like", | |||
PT_REGISTER_KERNEL("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.
这样直接改会导致pten kernel在运行时都没有被选到吧,兼容态是根据这个名字来搜索是否执行pten kernel的
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.
会选到
paddle/pten/core/convert_utils.cc
Outdated
@@ -20,6 +20,26 @@ limitations under the License. */ | |||
|
|||
namespace pten { | |||
|
|||
// the map between kernel name in fluid and pten | |||
const std::unordered_map<std::string, std::string> kernel_alias_name_map = { | |||
{"reshape2", "reshape"}, |
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.
这个会导致咱们让大家迁移的时候,还需要额外关注这个文件的更新和映射,能否在注册时一起声明下这个name
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.
如果用这种的话,建议这个map单独放到一个文件中管理
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
PR types
Others
PR changes
Others
Describe
Add alias kernel name for compatible with old kernel name and modify the kernel name in pten. This will make pten kernel's name more clear.