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

expose AppendBackward of ProgramDesc to python #4699

Merged
merged 3 commits into from
Oct 11, 2017

Conversation

jacquesqiao
Copy link
Member

@jacquesqiao jacquesqiao commented Oct 11, 2017

project: #4679
fix: #4694

wangkuiyi
wangkuiyi previously approved these changes Oct 11, 2017
@@ -27,6 +27,8 @@ extern std::unique_ptr<OperatorBase> Backward(
const OperatorBase& forwardOp,
const std::unordered_set<std::string>& no_grad_vars);

// TODO(someone): Add target as parameter and generate backward op
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's assign this TODO to some specific person when we create it.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -116,6 +117,11 @@ void BindProgramDesc(py::module &m) {
py::return_value_policy::reference)
.def("append_block", &ProgramDescBind::AppendBlock,
py::return_value_policy::reference)
.def("backward",
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 append_backward is a better name. backward means the process that executes gradient op one by one, not append them.

Copy link
Member Author

Choose a reason for hiding this comment

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

done


self.assertEqual(len(block.all_ops()), 1)
prog.backward(set())
self.assertEqual(len(block.all_ops()), 3)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add more check here to make sure additional ops are exactly what we want.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

Copy link
Member 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

@JiayiFeng JiayiFeng left a comment

Choose a reason for hiding this comment

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

LGTM

@jacquesqiao jacquesqiao merged commit 5e9d439 into PaddlePaddle:develop Oct 11, 2017
reyoung added a commit to reyoung/Paddle that referenced this pull request Oct 11, 2017
…backward"

This reverts commit 5e9d439, reversing
changes made to 134a073.
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.

expose backward of ProgramDesc
3 participants