-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix the div 0 error of sequence_concat #49963
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
004c1b7
fix the div 0 error of sequence_concat
Liyulingyue 499b526
bug fix
Liyulingyue a180f53
Merge branch 'PaddlePaddle:develop' into div0_4
Liyulingyue a9a83aa
replace fluid with static
Liyulingyue 23df7e2
fixed
Liyulingyue 70f5049
fix error
Liyulingyue 976f983
Merge branch 'PaddlePaddle:develop' into div0_4
Liyulingyue 257c6b4
Update test_sequence_concat.py
Liyulingyue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change intended to prevent division by zero at
SequenceConcatOp
'sInferShape
?If so, why only raise Exception when an input has shape
[0]
. In my opinion, when an input has a leading zero in its shape, like[0, 2, 3]
, an exception should be raised.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, I will try to solve it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, in the follow case, an exception have been writen.
If I simplely require that 'the input size must not be 0', some collisions may occur.
So, could you tell me where should I modify or what should I do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emmmm,就这个问题而言,因为是 InferShape 里出现了除第一个维度的需求,
'the input size must not be 0'
的检查是不是不太合适?when an input has a leading zero in its shape
对此的检查就刚刚好这个错误与本问题无关啊,只要你重新使用相同 name 定义了不同 shape 的 Variable 就会出现此错误,这里上文应该有一个定义过的
shape=(1, 0)
的y
,删掉或者将这个重命名即可(Jupyter 直接Restart kernel
)直接在 Python 端修改:
或者直接在 C++ 端增加一样的检查,比如这里 71 行后就很合适,个人觉得直接 C++ 端更好一些?
Paddle/paddle/fluid/operators/sequence_ops/sequence_concat_op.cc
Lines 71 to 86 in 3e5a6df
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
更新一下报错信息~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我也是觉得在 c++ 端添加 x_dim[0] 不能为 0 的检查会更好一些。
P.S. 由于现在 paddle 对 zero-sized tensor 支持不够好,所以目前添加这样的检查(无论是在 c++ 端还是在 Python 端)我觉得都 ok.
不过其实为了计算 feature_size 大可以用
product(x_shape[1: ])
的方式来计算而不必用x_numel / x_shape[0]
的方式计算. (P.S. paddle 的 lod tensor (多层不定长序列)的第 0 维表示递归折叠后的长度,而后面的可以称为 feature_shape,表示序列中的基础元素的形状)