-
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
add some basic math functor for SelectedRows #4801
add some basic math functor for SelectedRows #4801
Conversation
template struct SetConstant<platform::CPUPlace, float>; | ||
|
||
namespace detail { | ||
size_t FindPos(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.
return std::find(rows.begin(), rows.end(), value) - rows.begin();
df2d176
to
89758ad
Compare
…/Paddle into add_selected_rows_functor
@@ -130,6 +132,99 @@ void matmul<platform::CPUPlace, double>( | |||
matrix_b.data<double>(), beta, matrix_out->data<double>()); | |||
} | |||
|
|||
template struct SetConstant<platform::CPUPlace, float>; |
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.
Let us move the added code into paddle/operators/math/selected_rows.{h,cc,cu}
.
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
50f53b5
to
eb43f22
Compare
eb43f22
to
ab5dc9f
Compare
f6655d9
to
0d7b1fd
Compare
|
||
auto* out_data = out_value->data<T>(); | ||
auto* in1_data = in1_value.data<T>(); | ||
memory::Copy(boost::get<platform::CPUPlace>(out_place), out_data, |
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.
I'm not sure, if we have duplicated rows selected, the row value is copied multiple times?
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.
Yes, the row value will be just simply concated.
// concat rows
out_rows.insert(out_rows.end(), in1_rows.begin(), in1_rows.end());
out_rows.insert(out_rows.end(), in2_rows.begin(), in2_rows.end());
output->set_rows(out_rows);
No description provided.