diff --git a/paddle/pybind/protobuf.cc b/paddle/pybind/protobuf.cc index 3b2ac68714a4d8311cfac27514d3d34985fb6bb7..7af93cca99a79eec4c4cb29c4117b695a7e3f7ae 100644 --- a/paddle/pybind/protobuf.cc +++ b/paddle/pybind/protobuf.cc @@ -214,6 +214,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(); @@ -329,6 +335,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);