Skip to content
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

Merged
merged 7 commits into from
Aug 3, 2022

Conversation

Li-fAngyU
Copy link
Contributor

@Li-fAngyU Li-fAngyU commented Jul 10, 2022

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。

add paddle.bucketize api
@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Jul 10, 2022
@paddle-bot
Copy link

paddle-bot bot commented Jul 10, 2022

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@Li-fAngyU Li-fAngyU changed the title 【Hackathon No.5】为 Paddle 新增 bucketize 【PaddlePaddle Hackathon 3 No.5】为 Paddle 新增 bucketize Jul 10, 2022
'paddle.searchsorted')
if sorted_sequence.dim() != 1:
raise ValueError(
f"boundaries tensor must be 1 dimension, but got dim {sorted_sequence.dim()}"
Copy link
Contributor

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)
Copy link
Contributor

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?

@Li-fAngyU
Copy link
Contributor Author

Done

@Li-fAngyU Li-fAngyU requested a review from jeff41404 July 20, 2022 06:34
jeff41404
jeff41404 previously approved these changes Jul 27, 2022
Copy link
Contributor

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sunzhongkai588
Copy link
Contributor

需要补充中文文档至docs repo

@Li-fAngyU
Copy link
Contributor Author

@sunzhongkai588 已补充

sunzhongkai588
sunzhongkai588 previously approved these changes Jul 29, 2022
Copy link
Contributor

@sunzhongkai588 sunzhongkai588 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Li-fAngyU Li-fAngyU dismissed stale reviews from sunzhongkai588 and jeff41404 via d2e5a9a July 29, 2022 11:27
@Li-fAngyU Li-fAngyU requested a review from jeff41404 July 31, 2022 01:25
Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@Ligoml Ligoml left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for docs

@jeff41404 jeff41404 merged commit a0bf44f into PaddlePaddle:develop Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants