solve elementwise_add_grad tenosr copy bug#32095
Closed
thisjiang wants to merge 1 commit intoPaddlePaddle:developfrom
Closed
solve elementwise_add_grad tenosr copy bug#32095thisjiang wants to merge 1 commit intoPaddlePaddle:developfrom
thisjiang wants to merge 1 commit intoPaddlePaddle:developfrom
Conversation
…me before copy, test=develop
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
已确认
dout与dx、dy的dimension一定是相同的,问题出在其它地方,已关闭。前置PR:PR32051
BUG描述:
按之前的逻辑为例:
dout与dx的数据地址相同,且dout与dy的数据地址不同时,只需拷贝dout中的数据到dy中;dout的dimension与dy相同时这没有问题,但当两者不同时就出错了:TensorCopy会改变dy的dimension为dout的值,因此会对后续的计算造成影响。修复方案:
在
TensorCopy前先检查dout与dx、dy的dimension是否相同,若相同则进一步根据判断调用TensorCopy,否则直接调用SimpleElemwiseAddGradCUDAKernel。TODO:
使用
memory::Copy替代TensorCopy是不是更简单通用?不用在意dimension是否相同,拷贝大小取x->numel() * sizeof(T),这样只需保证dout的大小一定大于等于size即可(后者elementwise的原理可以保证)。