Skip to content
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

Merged
merged 14 commits into from
Oct 16, 2017

Conversation

QiJune
Copy link
Member

@QiJune QiJune commented Oct 13, 2017

No description provided.

@QiJune QiJune requested a review from reyoung October 13, 2017 22:03
template struct SetConstant<platform::CPUPlace, float>;

namespace detail {
size_t FindPos(const std::vector<int64_t>& rows, int64_t value) {
Copy link
Collaborator

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();

@QiJune QiJune changed the title add selected_rows add cpu functor add some basic math functor for SelectedRows Oct 14, 2017
@@ -130,6 +132,99 @@ void matmul<platform::CPUPlace, double>(
matrix_b.data<double>(), beta, matrix_out->data<double>());
}

template struct SetConstant<platform::CPUPlace, float>;
Copy link
Collaborator

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}.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@QiJune QiJune force-pushed the add_selected_rows_functor branch 3 times, most recently from 50f53b5 to eb43f22 Compare October 16, 2017 07:28

auto* out_data = out_value->data<T>();
auto* in1_data = in1_value.data<T>();
memory::Copy(boost::get<platform::CPUPlace>(out_place), out_data,
Copy link
Contributor

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?

Copy link
Member Author

@QiJune QiJune Oct 16, 2017

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);

@QiJune QiJune merged commit 86acf39 into PaddlePaddle:develop Oct 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants