Feature/pybind for protobuf desc#4397
Conversation
…/Paddle into feature/pybind_for_protobuf_desc
…/Paddle into feature/pybind_for_protobuf_desc
…/reyoung/Paddle into feature/pybind_for_protobuf_desc
… feature/pybind_for_protobuf_desc
… feature/pybind_for_protobuf_desc
…/reyoung/Paddle into feature/pybind_for_protobuf_desc
…/Paddle into feature/pybind_for_protobuf_desc
…/Paddle into feature/pybind_for_protobuf_desc
…/reyoung/Paddle into feature/pybind_for_protobuf_desc
…/Paddle into feature/pybind_for_protobuf_desc
|
|
||
| op.set_block_attr("block_attr", prog.block(0)) | ||
| self.assertEqual(0, op.get_block_attr("block_attr")) | ||
| self.assertEqual(core.AttrType.INT, op.attr_type("int_attr")) |
There was a problem hiding this comment.
this line should be moved to line 26
| }; | ||
|
|
||
| class OpDescBind { | ||
| public: |
There was a problem hiding this comment.
need a space before public/private/protected
paddle/pybind/protobuf.cc
Outdated
| } | ||
|
|
||
| void SetAttr(const std::string &name, const Attribute &v) { | ||
| this->attrs_[name] = v; |
|
|
||
| private: | ||
| OpDesc op_desc_; | ||
| std::unordered_map<std::string, std::vector<std::string>> inputs_; |
There was a problem hiding this comment.
should add a comment that: every method change these data members should set
need_update_ = true;
| return ops_.back().get(); | ||
| } | ||
|
|
||
| OpDescBind *PrependOp() { |
There was a problem hiding this comment.
what is the situation of PrependOp?
| .def( | ||
| "new_var", &BlockDescBind::NewVar, py::return_value_policy::reference) | ||
| .def("var", &BlockDescBind::Var, py::return_value_policy::reference) | ||
| .def("all_vars", |
There was a problem hiding this comment.
need interface:
has_input()
has_output()
has_var()for infer_shape
There was a problem hiding this comment.
Since when writing this PR, infer_shape has not been merged. So the interface will be added in next PR.
| return prog_->Block(static_cast<size_t>(this->desc_->parent_idx())); | ||
| } | ||
|
|
||
| void OpDescBind::SetBlockAttr(const std::string &name, BlockDescBind &block) { |
There was a problem hiding this comment.
我记得之前讨论是把BlockDisk的index存到 attr里边,这里为什么把整个结构都保存下来了,而且Get也只能Get到index
62a4fda to
de35098
Compare
| return it->second; | ||
| } | ||
|
|
||
| int GetBlockAttr(const std::string &name) const { |
There was a problem hiding this comment.
还有一个小问题,既然SetBlockAttr是保存了BlockDesc的结构,那GetBlockAttr何不直接返回BlockDesc?拿到BlockDesc也是可以拿到index的
There was a problem hiding this comment.
因为这个接口要返回给Python呀。。
No description provided.