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

Fix Scalar(bool) handling in toIValue #87179

Closed
wants to merge 3 commits into from

Conversation

lezcano
Copy link
Collaborator

@lezcano lezcano commented Oct 18, 2022

Stack from ghstack (oldest at bottom):

At the moment, they were casted to int64, which breaks quite a few
casting rules for example in ops.aten.

Quite a vintage bug, circa 2020.

With this fix, the following code prints torch.bool, rather than torch.int64.

import torch
msk = torch.tensor([False])
b = torch.tensor([False])
print(torch.ops.aten.where.ScalarSelf(msk, True, b).dtype)

At the moment, they were casted to `int64`, which breaks quite a few
casting rules for example in `ops.aten`.

[ghstack-poisoned]
@pytorch-bot pytorch-bot bot added the release notes: jit release notes category label Oct 18, 2022
@pytorch-bot
Copy link

pytorch-bot bot commented Oct 18, 2022

At the moment, they were casted to `int64`, which breaks quite a few
casting rules for example in `ops.aten`.

Quite a vintage bug, circa 2020.

With this fix, the following code prints `torch.bool`, rather than `torch.int64`.
```python
import torch
msk = torch.tensor([False])
b = torch.tensor([False])
print(torch.ops.aten.where.ScalarSelf(msk, True, b).dtype)
```

[ghstack-poisoned]
@lezcano lezcano added topic: bug fixes topic category ciflow/trunk Trigger trunk jobs on your pull request ciflow/periodic Trigger jobs ran periodically on master (periodic.yml) on the PR labels Oct 18, 2022
At the moment, they were casted to `int64`, which breaks quite a few
casting rules for example in `ops.aten`.

Quite a vintage bug, circa 2020.

With this fix, the following code prints `torch.bool`, rather than `torch.int64`.
```python
import torch
msk = torch.tensor([False])
b = torch.tensor([False])
print(torch.ops.aten.where.ScalarSelf(msk, True, b).dtype)
```

[ghstack-poisoned]
@lezcano
Copy link
Collaborator Author

lezcano commented Oct 18, 2022

@albanD there's lots of errors, but they all seem unrelated

@lezcano lezcano changed the title Fix bool handling in toIValue Fix Scalar(bool) handling in toIValue Oct 18, 2022
Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

SGTM
FYI @ezyang

@kit1980 kit1980 added the Merged label Mar 24, 2023
@facebook-github-bot facebook-github-bot deleted the gh/Lezcano/141/head branch June 8, 2023 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/periodic Trigger jobs ran periodically on master (periodic.yml) on the PR ciflow/trunk Trigger trunk jobs on your pull request Merged open source release notes: jit release notes category topic: bug fixes topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants