Skip to content

Commit

Permalink
fix SelectedRows rows() method gpu runtime error
Browse files Browse the repository at this point in the history
  • Loading branch information
QiJune committed Oct 16, 2017
1 parent 9706992 commit c65bdd9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion paddle/pybind/pybind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,17 @@ PYBIND11_PLUGIN(core) {
.def("set_height", &SelectedRows::set_height)
.def("height", &SelectedRows::height)
.def("set_rows", &SelectedRows::set_rows)
.def("rows", &SelectedRows::rows, py::return_value_policy::reference);
.def("rows", [](SelectedRows &self) {
#ifndef PADDLE_WITH_CUDA
return self.rows();
#else
auto rows = self.rows();
std::vector<int64_t> new_rows;
new_rows.reserve(rows.size());
std::copy(rows.begin(), rows.end(), std::back_inserter(new_rows));
return new_rows;
#endif
});

py::class_<Variable>(m, "Variable", R"DOC(Variable Class.
Expand Down

0 comments on commit c65bdd9

Please sign in to comment.