Skip to content

Commit

Permalink
Merge pull request #5 from 2742195759/pr_48213
Browse files Browse the repository at this point in the history
[bugfix] fix _find_op_path_ bugs in append_backward.
  • Loading branch information
phlrain authored Nov 24, 2022
2 parents 53b0eb6 + 25968b4 commit f380f10
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 4 additions & 0 deletions python/paddle/fluid/backward.py
Original file line number Diff line number Diff line change
Expand Up @@ -2221,6 +2221,10 @@ def _find_op_path_(
op.desc.output_arg_names(), output_names
):
relevant_op_flags[i] = True
if core.has_non_empty_grad_op_maker(op.type):
for name in op.desc.input_arg_names():
if name not in no_grad_set:
output_names.add(name)

op_path = [
block.ops[i] for i in range(len(block.ops)) if relevant_op_flags[i]
Expand Down
1 change: 0 additions & 1 deletion python/paddle/fluid/layers/rnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,6 @@ def _switch_grad(x, stop=False):

out_array = control_flow.create_array(dtype=flatten(inputs)[0].dtype)

init_array = control_flow.create_array(dtype=flatten(inputs)[0].dtype)
init_array = map_structure(
lambda x: control_flow.create_array(dtype=x.dtype), initial_states
)
Expand Down

0 comments on commit f380f10

Please sign in to comment.