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

function setitem support with stride #57023

Merged
merged 6 commits into from
Sep 12, 2023

Conversation

zoooo0820
Copy link
Contributor

@zoooo0820 zoooo0820 commented Sep 6, 2023

PR types

Function optimization

PR changes

Others

Description

Pcard-66985

With the introduction of the stride mechanism in dygraph, and the relevant OPs output view has been enabled by default, indexing in Paddle needs to be adjusted accordingly.

In dygraph mode:

  • __getitem__: Basic-indexing will output view of Tensor.
  • __setitem__: Advanced-indexing just assign value directly on the view of original Tensor, without an additional set_value. Moreover, we call set_value dygraph function instead of append_op, since the latter does not support the stride mechanism.

@paddle-bot
Copy link

paddle-bot bot commented Sep 6, 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.

x_tmp[:, 2] = 20

np.testing.assert_allclose(x.numpy(), np_data)

Copy link
Contributor

Choose a reason for hiding this comment

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

shall we add test case of ellipsis index

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, add a case to test ellipsis index.

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 b9673f6 into PaddlePaddle:develop Sep 12, 2023
27 checks passed
@zoooo0820 zoooo0820 deleted the slice_will_output_view branch September 12, 2023 05:02
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
* function setitem support with stride

* fix ut

* remove redundant dygraph checks

* add unittest for basic slice output view

* add Ellipsis case
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.

None yet

2 participants