-
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
[XPU] Add embedding plugin #56488
[XPU] Add embedding plugin #56488
Conversation
… seam_feat_opt
… seam_feat_opt
… seam_feat_opt
… seam_feat_opt
… seam_feat_opt
… seam_feat_opt
… seam_feat_opt
你的PR提交成功,感谢你对开源项目的贡献! |
d1da251
to
3303311
Compare
ym, | ||
padding_idx); | ||
#else | ||
r = xpu::plugin::embedding_tiny_dict<XPUType, int64_t>( |
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.
统一下名称吧 fast_embedding 以后各种 case 的加速版在 fast_embedding 的wrapper 内部判断。
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.
感觉 fast 名称不好啊,没办法显示出 kernel 的具体场景,我这个是针对小词表下面的 kernel 优化,感觉这个名称更合适。一个 plugin 倒可以改成 fast,如果接下来有需要针对 embedding 其他场景进行优化,就不太好取名字了。
#endif | ||
} else { | ||
#ifndef PADDLE_WITH_XPU_PLUGIN | ||
int64_t *ids_tt = RAII_GUARD.alloc_l3_or_gm<int64_t>(ids_t->numel()); |
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.
xpu::embedding 不支持 int32 的 index 吗?
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.
这个是之前 phi kernel 的逻辑, kernel 里面会插入 cast 算子将 int32 转成 int64,昆仑2我看是支持int32的,昆仑一不清楚,所以为了兼容性,我没有改原来的逻辑
GET_IR_NODE(embedding); | ||
GET_IR_NODE(embedding_ids); | ||
auto* block = cast->Op()->Block(); | ||
auto cast_node_attr_in_dtype = cast->Op()->GetAttrIfExists<int>("in_dtype"); |
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.
- 有考虑 in_dtype 为 int32,out_dtype 为 int64 的情况吗?理论上这个情况下,可以把 cast 删除。
- 理论上不应该限制 in_dtype 吧?是不是只看 out_dtype==int64就行?
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.
这个在 cast + embedding 组合里面感觉应该不会出现,embedding 支持 int32,理论上不会出现你这个情况
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.
这个我改下,防止模型出现这种情况吧,目前模型里面是没有这种情况的。
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
New features
PR changes
Others
Description
Add embedding kernel plugin for small size dict.