Skip to content

Conversation

@izdeby
Copy link
Contributor

@izdeby izdeby commented May 28, 2019

Stack from ghstack:

This PR is a part of a stack which will change result tensor type of comparison ops from uint8 to bool. As this change is rather big and a lot of prep work is needed, im breaking it into a stack.

Changes in this PR:

  • Add possibility to index scalars with a bool mask.

Differential Revision: D15530498

@pytorchbot pytorchbot added module: autograd Related to torch.autograd, and the autograd engine in general module: operators module: pybind Related to our Python bindings / interactions with other Python libraries labels May 28, 2019
Added possibility to index scalars by bool masks

gh-metadata: pytorch pytorch 21030 gh/izdeby/1/head
@ezyang
Copy link
Contributor

ezyang commented May 28, 2019

Add possibility to index scalars with a bool mask.

Why? :)

uintMask = torch.tensor(True, dtype=torch.uint8, device=device)
boolMask = torch.tensor(True, dtype=torch.bool, device=device)
self.assertEqual(a[uintMask], a[boolMask])
self.assertEqual(a[uintMask].dtype, a[boolMask].dtype)
Copy link
Contributor

Choose a reason for hiding this comment

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

This test feels a little goofy, because aren't you intending to change the uintMask behavior in the near future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well once its changed i will update the test but for now i want to show that the result is identical, as expected.

@ezyang
Copy link
Contributor

ezyang commented May 28, 2019

Should there be documentation updates in these PRs?

@izdeby
Copy link
Contributor Author

izdeby commented May 28, 2019

@ezyang,

Why? :)

  1. It works for uint8 so makes sense to enable same behavior for bool.
  2. Its part of masking/indexing and it works for tensors but not for scalars yet.
  3. We will need this for tests in future once there will be the pr which actually changes the result tensor type.

Should there be documentation updates in these PRs?
Mmmm im not sure. I mean, yes they should but we didn't really update documentation for any of the previous PRs so i was preparing myself for a big documentation PR once the whole thing is done.

@izdeby izdeby requested a review from ezyang May 28, 2019 21:39
@izdeby
Copy link
Contributor Author

izdeby commented May 28, 2019

@pytorchbot retest this please

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

I'm getting somewhat nervous about the testing, because I feel like there is almost definitely existing tests for uintMask and the right thing would be adapt them to test boolMask too, but that does not appear to have been done in this PR. But if you want to do this all as a big pass when you start changing uintMask behavior in BC-breaking ways, I guess that's fine.

@zou3519 zou3519 deleted the gh/izdeby/1/head branch May 29, 2019 16:35
@facebook-github-bot
Copy link
Contributor

@izdeby merged this pull request in 00c1584.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: autograd Related to torch.autograd, and the autograd engine in general module: pybind Related to our Python bindings / interactions with other Python libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants