Skip to content

Commit

Permalink
fix cross_entropy when run static graph mode of mlu and npu
Browse files Browse the repository at this point in the history
  • Loading branch information
qipengh committed Mar 16, 2022
1 parent dce87e3 commit a6f9865
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python/paddle/nn/functional/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -1792,12 +1792,16 @@ def cross_entropy(input,
helper = LayerHelper('softmax_with_cross_entropy', **locals())
softmax = helper.create_variable_for_type_inference(dtype=input.dtype)
out = helper.create_variable_for_type_inference(dtype=input.dtype)

outputs = {'Softmax': softmax, 'Loss': out}
if core.is_compiled_with_npu() or core.is_compiled_with_mlu():
backprop = helper.create_variable_for_type_inference(dtype=input.dtype)
outputs['Backprop'] = backprop
helper.append_op(
type='softmax_with_cross_entropy',
inputs={'Logits': input,
'Label': label},
outputs={'Softmax': softmax,
'Loss': out},
outputs=outputs,
attrs=attrs)

if weight is not None:
Expand Down

1 comment on commit a6f9865

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

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

Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉

Please sign in to comment.