-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Move embedding to phi #39901
Move embedding to phi #39901
Conversation
… move_embedding_to_phi
… move_embedding_to_phi
Sorry to inform you that ab1042f's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
… move_embedding_to_phi
… move_embedding_to_phi
namespace phi { | ||
|
||
template <typename T, typename Context> | ||
struct LookupTableV2GradCPUFunctor { |
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下面LookupTableV2要不要都统一成Embedding?
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
// paddings makes no sense and we don't deal with it in backward. | ||
{ | ||
auto* d_output = &out_grad_; | ||
// auto d_table = weight_grad_; |
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.
done
ids_data[i], | ||
N, | ||
phi::errors::InvalidArgument( | ||
"Variable value (input) of OP(fluid.layers.embedding) " |
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.
fluid.layers.embedding->paddle.nn.functional.embedding
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
ids_data[i], | ||
0, | ||
phi::errors::InvalidArgument( | ||
"Variable value (input) of OP(fluid.layers.embedding) " |
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.
fluid.layers.embedding->paddle.nn.functional.embedding
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
}; | ||
|
||
template <typename T, typename Context> | ||
void EmbeddingSparseGradKernel(const Context& ctx, |
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可以放到selected_rows下
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.
selected rows的拆分,单独用一个pr来做
|
||
namespace phi { | ||
|
||
template <typename T, typename Context> |
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.
这个文件可以放到selected_rows目录下
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.
selected rows的拆分,单独用一个pr来做
#include "paddle/phi/kernels/funcs/embedding_util.h" | ||
|
||
#include "paddle/fluid/framework/convert_utils.h" | ||
#include "paddle/fluid/framework/data_type.h" |
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下的data_type.h
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
ids_data[i], | ||
0, | ||
phi::errors::InvalidArgument( | ||
"Variable value (input) of OP(fluid.layers.embedding) " |
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.
fluid.layers.embedding->paddle.nn.functional.embedding
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
auto output_t = out_; | ||
int64_t row_width = table_t.value().dims()[1]; | ||
const auto* table = table_t.value().template data<T>(); | ||
auto* output = output_t->template mutable_data<T>(dev_ctx_.GetPlace()); |
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.
使用dec_ctx.Alloc
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
auto input_data_type = | ||
paddle::framework::TransToProtoVarType(table_t.value().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.
这里可以不转ProtoVarType,直接用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.
done
} else if (input.dtype() == phi::DataType::INT64) { | ||
functor.template apply<int64_t>(); | ||
} else { | ||
PADDLE_THROW("emebdding input only support int32 and 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.
这不符合报错规范,需要加报错类型
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.
已修改
} else if (input.dtype() == phi::DataType::INT64) { | ||
functor.template apply<int64_t>(); | ||
} else { | ||
PADDLE_THROW("emebdding input only support int32 and 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.
同上
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.
已修改
} else if (input.dtype() == phi::DataType::INT64) { | ||
functor.template apply<int64_t>(); | ||
} else { | ||
PADDLE_THROW("emebdding input only support int32 and 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.
同上,共性问题,麻烦都check一下
namespace phi { | ||
|
||
template <typename T, typename Context> | ||
void SparseWeightEmbeddingGradKernel(const Context& ctx, |
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.
SelectedRows相关的尽快移到selected_rows目录
… move_embedding_to_phi
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.
如评论,selected rows kernel后续再调整下目录和形式
TODO已记录 |
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
Traceback (most recent call last): embedding量化后,导入静态模型报错。 |
embedding量化代码
if name == 'main': |
@1998-Chen 这个问题在issue里提下吧,在PR下面不太好跟踪 |
PR types
Breaking changes
PR changes
OPs
Describe
move embedding to phi