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

Support index is list bool for getitem in static mode #33298

Merged
merged 2 commits into from
Jun 10, 2021

Conversation

liym27
Copy link
Contributor

@liym27 liym27 commented Jun 2, 2021

PR types

New features

PR changes

APIs

Describe

As the title

For example:

tensor_x = paddle.to_tensor(np.array([[1,2],[3,4]]).astype(np.float32))
tensor_x[[True,False]] 

@paddle-bot-old
Copy link

paddle-bot-old bot commented Jun 2, 2021

✅ This PR's description meets the template requirements!
Please wait for other CI results.

@paddle-bot-old
Copy link

paddle-bot-old bot commented Jun 2, 2021

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@liym27 liym27 requested a review from zhhsplendid June 3, 2021 02:50
@liym27 liym27 force-pushed the static_getitem_bool branch 2 times, most recently from 2b693f0 to 48cceb8 Compare June 9, 2021 03:39
@liym27 liym27 changed the title Static getitem bool Support index is list bool for getitem in static mode Jun 9, 2021
new_slice_item = []
for idx, ele in enumerate(slice_item):
if not isinstance(ele, bool):
raise TypeError("Only support bool in list.")
Copy link
Member

Choose a reason for hiding this comment

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

Here the TypeError should be "Mixed bool index with other types is not supported"

"Only support bool in list." may confuse users that we can only use boolean 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.

Thanks, done.

if not isinstance(i, int):
raise TypeError("Only support int value in list")
if not isinstance(i, (int, bool)):
raise TypeError("Only support int or bool in list.")
Copy link
Member

Choose a reason for hiding this comment

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

"Only support int or bool in list" -> "Only support int or bool in index list"

Otherwise users may be confused about the list thing, them may not know we refer to the index list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done.

Copy link
Member

@zhhsplendid zhhsplendid left a comment

Choose a reason for hiding this comment

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

LGTM

@liym27 liym27 merged commit a225636 into PaddlePaddle:develop Jun 10, 2021
lanxianghit pushed a commit that referenced this pull request Jun 15, 2021
…ist/Tensor/None/Ellipsis/bool (#33528)

* [cherry-pick 2.1] Polish code for _getitem_impl_ (#32868)

* [cherry-pick] Polish code for setitem and getitem (#32911)

* [slice getitem] Support getitem idx is Tensor or List (#33000)

* [getitem] Support index is None for getitem in static mode (#33001)

* [Static getitem] Support static Variable getitem for Ellipsis index (#32876)

* [static getitem]Support index is list bool for getitem in static mode (#33298)
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