[Custom operator] Fix custom operator backward=None bug#48656
Merged
jiahy0825 merged 1 commit intoDec 5, 2022
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
chenwhql
approved these changes
Dec 5, 2022
lxsbupt
pushed a commit
to lxsbupt/Paddle
that referenced
this pull request
Dec 17, 2022
jiahy0825
added a commit
to jiahy0825/Paddle
that referenced
this pull request
Dec 20, 2022
phlrain
pushed a commit
that referenced
this pull request
Dec 27, 2022
* [Release2.4] Revert python link prs (#48573) * Revert "Fix mac link python (#48017)" This reverts commit 3fa7a73. * Revert "[Cherry-pick] Fix python link error (#47811)" This reverts commit ff642c6. * Update config.go * fix custom operator backward=None (#48656) * [Custom Extension] Fix custom double_grad backward=None (#49224) * fix custom double_grad backward=None * fix custom_relu.cu bug && polish testcase of double_grad * remove old dynamic graph test * add import fluid * add import fluid Co-authored-by: Chen Weihang <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 types
Bug fixes
PR changes
OPs
Describe
Bug describes: when custom backward op outputs gradient with a discrete order, the output of some gradient=None.
For example: backward op's input = {a, b, c, d, e}, output = {a@GRAD, d@GRAD, e@GRAD}, the output of d@GRAD and e@GRAD will be None.
Reason: The order of
RunCustomOpNode::operator(): line220incustom_operator_node.ccis {a@GRAD, null, null, d@GRAD, e@GRAD}. However, the order ofeager_api_run_custom_op: line560ineager_functions.ccis {a@GRAD, d@GRAD, e@GRAD, null, null}.Change: Change the order in
RunCustomOpNode::operator()to {a@GRAD, d@GRAD, e@GRAD, null, null}本 PR 修复了自定义算子反向 op 的输出值可能为 None 的 bug,当用户的输出梯度不是连续输出时(例如输出第0、3、4个前向输入的梯度时),第3、4个梯度会被置为 None,这是由于对反向 op 的输出梯度进行处理时,
RunCustomOpNode::operator(): line220和eager_api_run_custom_op: line560的动作不一致。更改为按照RunCustomOpNode::operator()对齐,在反向 op 的输出梯度后面,填充不需要梯度的输出,修改后的返回值为 {第 0 个梯度,第 3 个梯度,第 4 个梯度,null, null}