Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Category
Execute Infrastructure
PR Types
Improvements
Description
Paddle 对于如下代码会报错:
报错内容为:
如下代码有同样的问题:
第一种情况,用户提供了c和d的梯度,那么通过反向回传获得的梯度该怎么办。实测torch.autograd.grad和paddle.grad都是将用户提供的梯度以及回传算出的梯度加和。因此,paddle.autograd.backward也有必要这么做。
第二种情况,是paddle.autograd.backward存在bug。
这两种错误在paddle.autograd.backward时会发生,在paddle.grad时不会发生,因为paddle.grad会走PreparedForGeneralGrad,对反向图做剪枝等优化。
Pcard-67164