From 1bfa0e130a17613c0b0e2108e7d220d4630e928a Mon Sep 17 00:00:00 2001 From: fengjiayi Date: Mon, 25 Sep 2017 13:48:13 -0700 Subject: [PATCH] Add `Prepend` for BlockDescBind --- paddle/pybind/protobuf.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/paddle/pybind/protobuf.cc b/paddle/pybind/protobuf.cc index de6db60730b..f119a12e98f 100644 --- a/paddle/pybind/protobuf.cc +++ b/paddle/pybind/protobuf.cc @@ -104,6 +104,12 @@ public: return ops_.back().get(); } + OpDescBind *PrependOp() { + need_update_ = true; + ops_.emplace_front(new OpDescBind()); + return ops_.front().get(); + } + void Sync() { if (need_update_) { auto &op_field = *this->desc_->mutable_ops(); @@ -224,6 +230,9 @@ void BindBlockDesc(py::module &m) { .def("append_op", &BlockDescBind::AppendOp, py::return_value_policy::reference) + .def("prepend_op", + &BlockDescBind::PrependOp, + py::return_value_policy::reference) .def("new_var", &BlockDescBind::NewVar, py::return_value_policy::reference); -- GitLab