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

Optimize performance of advanced getitem #60254

Merged
merged 3 commits into from
Dec 25, 2023

Conversation

zoooo0820
Copy link
Contributor

@zoooo0820 zoooo0820 commented Dec 22, 2023

PR types

Performance optimization

PR changes

Others

Description

Pcard-66985

This PR optimize the advanced index __getitem__ performance.

  • For int tensor case: replacing the slow broadcast_tensors to broadcast_shape and expand. It will be much faster in case no need broadcast, and faster than broadcast_tensors.

  • For bool tensor case: replacing the nonzero + gather_nd to masked_select since the latter one is much faster. Moreover, the all-dtype support is added for kernel MaskedSelect and MaskedSelectedGrad

Copy link

paddle-bot bot commented Dec 22, 2023

你的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.

@zoooo0820 zoooo0820 changed the title replace broadcast_tensors to expand Optimize performance of advanced getitem Dec 22, 2023
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

@jeff41404 jeff41404 merged commit f048329 into PaddlePaddle:develop Dec 25, 2023
29 checks passed
@zoooo0820 zoooo0820 deleted the optimize_broadcast_index branch December 25, 2023 07:11
Wanglongzhi2001 pushed a commit to Wanglongzhi2001/Paddle that referenced this pull request Jan 7, 2024
* replace broadcast_tensors to expand

* static mode still use broadcast-tensors, since dynamic shape -1 cannot be compared

* optimize bool index getting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants