Skip to content

Commit

Permalink
fix raise bug
Browse files Browse the repository at this point in the history
  • Loading branch information
S-HuaBomb committed Aug 27, 2022
1 parent eca0483 commit 4ca5c41
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions python/paddle/tensor/math.py
Expand Up @@ -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)
elif mode == 'wrap':
# The out of range indices are constrained by taking the remainder.
index_1d = paddle.where(index_1d < 0,
Expand Down

0 comments on commit 4ca5c41

Please sign in to comment.