Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix several bugs in compile time backward and Protobuf desc #4894

Merged
merged 28 commits into from
Oct 18, 2017

Conversation

JiayiFeng
Copy link
Collaborator

@JiayiFeng JiayiFeng commented Oct 18, 2017

fixes #4893

This PR is branched from #4868, so some changed may belong to that one and have no relationship with this topic.

reyoung and others added 25 commits October 11, 2017 12:08
and Rename `Sync` to `Flush`
Since lots of types can be cast to bool
@@ -55,6 +55,12 @@ OpDescBind *BlockDescBind::AppendOp() {
return ops_.back().get();
}

void BlockDescBind::AppendAllocatedOp(std::unique_ptr<OpDescBind> &op_desc) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is pretty hard to figure out the op_desc has been changed inside AppendAllocatedOp for others.

It is better to use std::move outside, and accept the rvalue reference here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

void BlockDescBind::AppendAllocatedOp(std::unique_ptr<OpDescBind> &op_desc) {
need_update_ = true;
ops_.emplace_back(std::move(op_desc));
return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return is not needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

OpDescBind *PrependOp();

std::vector<OpDescBind *> AllOps() const;

int OpSize() const { return ops_.size(); }
Copy link
Collaborator

@reyoung reyoung Oct 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return size_t

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

OpDescBind *PrependOp();

std::vector<OpDescBind *> AllOps() const;

int OpSize() const { return ops_.size(); }

OpDescBind *Op(int idx) const { return ops_.at(idx).get(); }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use size_t as idx, also maybe do not mark this method as const since it will change the program.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -176,8 +176,10 @@ void BindBlockDesc(py::module &m) {
py::return_value_policy::reference)
.def("all_vars", &BlockDescBind::AllVars,
py::return_value_policy::reference)
.def("all_ops", &BlockDescBind::AllOps,
py::return_value_policy::reference)
// .def("all_ops", &BlockDescBind::AllOps,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator

@reyoung reyoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basic LGTM, instead of some tiny enhancements.

Copy link
Collaborator

@reyoung reyoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

splendid works. Thanks

@JiayiFeng JiayiFeng merged commit a204fef into PaddlePaddle:develop Oct 18, 2017
@JiayiFeng JiayiFeng deleted the fix_backward_bug branch October 18, 2017 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Several bugs in compile time backward and Protobuf desc
2 participants