-
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
【PaddlePaddle Hackathon 3 No.16】为 Paddle 新增 API paddle.take #44741
Changes from 1 commit
982d01e
69b0a3e
b07c062
09d2836
c8482f6
0665e50
c5a9e16
10b41c4
6852760
9649b87
ec1cfd7
6806a8f
27b6943
5d32c52
b35d831
cc2f4f4
c4161f2
aaee858
ca2604f
5979d5f
7b3fc1d
668964d
64b688a
cdd1080
eca0483
4ca5c41
9fb6896
7fd6c85
046ff44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4863,9 +4863,7 @@ def take(x, index, mode='raise', name=None): | |
|
||
if mode == 'raise': | ||
# This processing enables 'take' to handle negative indexes within the correct range. | ||
# Negative indexes can be enabled, | ||
# but out-of-range indexes will report an error in the following paddle.index_select | ||
index_1d = paddle.where(index_1d < 0, index_1d % max_index, index_1d) | ||
index_1d = paddle.where(index_1d < 0, index_1d + max_index, index_1d) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @S-HuaBomb 这个修改是哪个case会出bug呢? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
Got it. 可以针对这个case补充一个报错的单测么? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已加,done. |
||
elif mode == 'wrap': | ||
# The out of range indices are constrained by taking the remainder. | ||
index_1d = paddle.where(index_1d < 0, | ||
|
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.
可以补充下注释,negative indexes可以enable,但越界的索引会在下面的index_select报错
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.
THX,Done