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

Move Dygraph Indexing Parsing to Pybind #58643

Merged
merged 25 commits into from
Nov 22, 2023

Conversation

zoooo0820
Copy link
Contributor

@zoooo0820 zoooo0820 commented Nov 3, 2023

PR types

Performance optimization

PR changes

Others

Description

Pcard-66985

For now, although there there is already complete indexing (i.e. __getitem__ / __setitem__) functional support, almost all the indexing parsing parts are running in Python, which brings much performance overhead.

In this PR, we move indexing parsing of dygraph from Python to Pybind, aiming to optimize the performance (For static mode, still in Python).

some other things in this pr:

  • add a fast path for single tensor getting (like x[tensor[1,2]] ): by replace the stack to unsqueeze.
  • remove non-necessary transpose in advanced getting.
  • remove any check in bool-mask indexing, since the any kernel and gpu->cpu memcpy is quite slow.
  • remove cond in bool-mask indexing, since currently this conditional block cannot be parsed in PIR

For convenience of review, the old indexing-parsing code will be deleted later.

Copy link

paddle-bot bot commented Nov 3, 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 [Just for Test] Indexing to pybind Move Dygraph Indexing Parsing to Pybind Nov 17, 2023
paddle/fluid/pybind/slice_utils.h Outdated Show resolved Hide resolved
paddle/fluid/pybind/slice_utils.h Show resolved Hide resolved
paddle/fluid/pybind/slice_utils.h Show resolved Hide resolved
Copy link
Contributor

@wanghuancoder wanghuancoder 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

@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 617bdb9 into PaddlePaddle:develop Nov 22, 2023
28 checks passed
@zoooo0820 zoooo0820 deleted the indexing_to_pybind branch November 22, 2023 03:30
SecretXV pushed a commit to SecretXV/Paddle that referenced this pull request Nov 28, 2023
* start down to pybind

* basic-getitem down

* fix compile error; basic-getitem seems work fine

* finish advanced-getitem, runs well but still has bug to fix

* fix parsing bug; getitem seems ok

* finish setitem, still has bug to fix

* fix some bug in advanced setitem

* fix CI error about bool-tensor indexing

* fix advance-indexing ci error

* remove transpose if there is no need

* support single py_boolean in index

* add assert densetensor to avoid error in auto-parallel mode

* add fast path for case single int tensor in getitem

* change set_value_dygraph_function to ad_func

* change vector type and fix the set_value_grad ut

* fix inplace version error in backward by assign

* remove any-check in bool tensor to boost getitem

* remove no-used python code, keep xpu code to fix; py-code add fast path from stack to unsqueeze

* fix py_bool cuda error

* fix cuda config error when gpu_memory_available after all-false bool-tensor indexing

* fix ci in 0-size gather_nd indexing

* add dist tensor check
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.

3 participants