-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
expose AppendBackward of ProgramDesc to python #4699
Conversation
paddle/framework/backward.h
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
paddle/pybind/protobuf.cc
Outdated
@@ -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", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
project: #4679
fix: #4694