Skip to content

Commit

Permalink
Do not sum output if that output is not a gradient
Browse files Browse the repository at this point in the history
* increament is default inplace
  • Loading branch information
reyoung committed Nov 9, 2017
1 parent 6d41bfb commit c9fc7ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions paddle/framework/backward.cc
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,11 @@ std::vector<std::unique_ptr<OpDescBind>> MakeBlockBackward(

for (const auto& desc : op_grads) {
for (const std::string& out_name : desc->OutputArgumentNames()) {
if (out_name.find("@GRAD") == std::string::npos) {
// Not all outputs of a backward operator is a gradient. Only gradient
// need to be sum. Skip variables are not gradient.
continue;
}
dup_out_ops[out_name].emplace_back(grad_desc_idx);
}
++grad_desc_idx;
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/v2/framework/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ def zeros(shape, dtype, main_program=None):
return fill_constant(value=0.0, **locals())


def increment(x, value=1.0, in_place=False, main_program=None):
def increment(x, value=1.0, in_place=True, main_program=None):
helper = LayerHelper("increment", **locals())
if in_place:
tmp = x
Expand Down

0 comments on commit c9fc7ba

Please sign in to comment.