-
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.5】为 Paddle 新增 bucketize #44195
Conversation
add paddle.bucketize api
你的PR提交成功,感谢你对开源项目的贡献! |
python/paddle/tensor/search.py
Outdated
'paddle.searchsorted') | ||
if sorted_sequence.dim() != 1: | ||
raise ValueError( | ||
f"boundaries tensor must be 1 dimension, but got dim {sorted_sequence.dim()}" |
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.
it is better to understand if using sorted_sequence
instead of boundaries tensor
paddle.disable_static(place) | ||
sorted_sequence = paddle.to_tensor(self.sorted_sequence) | ||
self.assertRaises(ValueError, paddle.bucketize, self.x, | ||
sorted_sequence) |
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 is a test case "错误检查:未输入x和sorted_sequence时,能否正确抛出错误" in rfc, shall we add this test case?
Done |
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.
LGTM
需要补充中文文档至docs repo |
@sunzhongkai588 已补充 |
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.
LGTM
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.
LGTM
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.
LGTM for docs
PR types
New features
PR changes
APIs
Describe
RFC的PR链接: PaddlePaddle/community#176
中文文档的PR链接: PaddlePaddle/docs#5089
为 Paddle 新增 bucketize API
paddle.bucketize 为 paddle.searchsorted 的sorted_sequence 在1维情况下的特例。比如输入数据 x = paddle.to_tensor([[0, 8, 4, 16], [-1, 2, 8, 4]]),sorted_sequence=paddle.to_tensor([2, 4, 8, 16]),则 paddle.bucketize(x, sorted_sequence) 或 x.bucketize(sorted_sequence) 得到 [[0, 2, 1, 3], [0, 0, 2, 1]],paddle.bucketize(x, sorted_sequence, right=True) 或 x.bucketize(sorted_sequence, right=True) 得到 [[0, 3, 2, 4], [0, 1, 3, 2]] 。此API需支持的调用路径为:paddle.bucketize 和 Tensor.bucketize。