-
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
Lookup table support selected rows as parameter #9575
Lookup table support selected rows as parameter #9575
Conversation
… lookup_table_support_SelectedRows_as_parameter
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!
auto *table_t = context.Input<SelectedRows>("W"); | ||
table_dim = table_t->value().dims(); | ||
} else { | ||
PADDLE_THROW("table only support LoDTensor and SelectedRows"); |
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.
table => LookupTable
support => supports
framework::ToDataType(table_var->Get<SelectedRows>().value().type()), | ||
ctx.device_context()); | ||
} else { | ||
PADDLE_THROW("W should be LoDTensor or SelectedRows"); |
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.
The parameter W of a LookupTable must be either LoDTensor or SelectedRows
@@ -25,56 +28,88 @@ namespace operators { | |||
using Tensor = framework::Tensor; | |||
using LoDTensor = framework::LoDTensor; | |||
using SelectedRows = framework::SelectedRows; | |||
using DDim = framework::DDim; | |||
|
|||
static constexpr int64_t kNoPadding = -1; |
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.
static
means that this variable is not exposed and is often used in .cc files. Why do we need static in this header file?
|
||
static constexpr int64_t kNoPadding = -1; | ||
|
||
inline size_t getIndex(const std::vector<int64_t> &rows, int64_t 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.
getIndex
is not style-compatible. Should be GetIndex
.
Also, GetIndex is a too general name; we might need a specific name, or move it into a class, which represents the context of the 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.
Ok, will move it to selected_rows.cc
auto *table_t = context.Input<SelectedRows>("W"); | ||
table_dim = table_t->value().dims(); | ||
} else { | ||
PADDLE_THROW("table only support LoDTensor and SelectedRows"); |
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.
The parameter W of LookupTable must be either LoDTensor or SelectedRows.
fix: #9576
task_list: #9211
project: https://github.com/PaddlePaddle/Paddle/projects/56