提交 dcc51da4 编写于 作者: F fengjiayi

update pybind

上级 1a0fc5d8
...@@ -174,12 +174,23 @@ void BindBlockDesc(py::module &m) { ...@@ -174,12 +174,23 @@ void BindBlockDesc(py::module &m) {
std::string name = byte_name; std::string name = byte_name;
return self.HasVar(name); return self.HasVar(name);
}) })
.def("has_var_recursive",
[](BlockDescBind &self, py::bytes byte_name) {
std::string name = byte_name;
return self.HasVarRecursive(name);
})
.def("find_var", .def("find_var",
[](BlockDescBind &self, py::bytes byte_name) { [](BlockDescBind &self, py::bytes byte_name) {
std::string name = byte_name; std::string name = byte_name;
return self.FindVar(name); return self.FindVar(name);
}, },
py::return_value_policy::reference) py::return_value_policy::reference)
.def("find_var_recursive",
[](BlockDescBind &self, py::bytes byte_name) {
std::string name = byte_name;
return self.FindVarRecursive(name);
},
py::return_value_policy::reference)
.def("all_vars", &BlockDescBind::AllVars, .def("all_vars", &BlockDescBind::AllVars,
py::return_value_policy::reference) py::return_value_policy::reference)
.def("op_size", &BlockDescBind::OpSize) .def("op_size", &BlockDescBind::OpSize)
...@@ -208,7 +219,8 @@ void BindVarDsec(py::module &m) { ...@@ -208,7 +219,8 @@ void BindVarDsec(py::module &m) {
.def("set_shape", &VarDescBind::SetShape) .def("set_shape", &VarDescBind::SetShape)
.def("set_dtype", &VarDescBind::SetDataType) .def("set_dtype", &VarDescBind::SetDataType)
.def("shape", &VarDescBind::Shape, py::return_value_policy::reference) .def("shape", &VarDescBind::Shape, py::return_value_policy::reference)
.def("dtype", &VarDescBind::GetDataType) .def("dtype", &VarDescBind::GetDataType,
py::return_value_policy::reference)
.def("lod_level", &VarDescBind::GetLodLevel) .def("lod_level", &VarDescBind::GetLodLevel)
.def("set_lod_level", &VarDescBind::SetLoDLevel) .def("set_lod_level", &VarDescBind::SetLoDLevel)
.def("type", &VarDescBind::GetType) .def("type", &VarDescBind::GetType)
...@@ -240,7 +252,9 @@ void BindOpDesc(py::module &m) { ...@@ -240,7 +252,9 @@ void BindOpDesc(py::module &m) {
.value("BLOCK", AttrType::BLOCK); .value("BLOCK", AttrType::BLOCK);
py::class_<OpDescBind> op_desc(m, "OpDesc", ""); py::class_<OpDescBind> op_desc(m, "OpDesc", "");
op_desc.def("__init__", [](OpDescBind &self) { new (&self) OpDescBind(); }) op_desc
.def("__init__", [](OpDescBind &self) { new (&self) OpDescBind(); },
py::return_value_policy::reference)
.def("type", &OpDescBind::Type) .def("type", &OpDescBind::Type)
.def("set_type", &OpDescBind::SetType) .def("set_type", &OpDescBind::SetType)
.def("input", &OpDescBind::Input) .def("input", &OpDescBind::Input)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册