8000 Support bool input tensors for argmax / argmin / sort / topk and other functions · Issue #35529 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

Support bool input tensors for argmax / argmin / sort / topk and other functions #35529

8000
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

Open
Tracked by #61417
vadimkantorov opened this issue Mar 27, 2020 · 2 comments
Labels
enhancement Not as big of a feature, but technically not a bug. Should be easy to fix module: reductions triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@vadimkantorov
Copy link
Contributor
vadimkantorov commented Mar 27, 2020

argmax and other functions make sense for finding position of True element. Functions working with uint8 should likely be able to handle torch.bool as well.

In [16]: torch.__version__
Out[16]: '1.5.0.dev20200310'
In [11]: torch.ones(3, dtype = torch.bool).argmax()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
~/convasr/ot/vis.py in <module>
----> 1 torch.ones(3, dtype = torch.bool).argmax()

RuntimeError: "argmax_cpu" not implemented for 'Bool'

In [12]: torch.ones(3, dtype = torch.bool).argmin()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
~/convasr/ot/vis.py in <module>
----> 1 torch.ones(3, dtype = torch.bool).argmin()

RuntimeError: "argmin_cpu" not implemented for 'Bool'

In [13]: torch.ones(3, dtype = torch.bool).argsort()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
~/convasr/ot/vis.py in <module>
----> 1 torch.ones(3, dtype = torch.bool).argsort()

RuntimeError: _th_sort not supported on CPUType for Bool

In [14]: torch.ones(3, dtype = torch.bool).topk(1)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
~/convasr/ot/vis.py in <module>
----> 1 torch.ones(3, dtype = torch.bool).topk(1)

RuntimeError: "topk_cpu" not implemented for 'Bool'

In [15]: torch.ones(3, dtype = torch.bool).sort()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
~/convasr/ot/vis.py in <module>
----> 1 torch.ones(3, dtype = torch.bool).sort()

RuntimeError: _th_sort not supported on CPUType for Bool
@agolynski agolynski added enhancement Not as big of a feature, but technically not a bug. Should be easy to fix triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Mar 27, 2020
@vadimkantorov
Copy link
Contributor Author

torch.ones(1, dtype = torch.bool).to(torch.bool) doesn't seem to copy whereas torch.ones(1, dtype = torch.bool).to(torch.uint8) does. I guess this is another case for #29013

@vadimkantorov vadimkantorov changed the title Support bool input tensors for argmax and other functions Support bool input tensors for argmax / argmin and other functions Nov 24, 2021
@vadimkantorov vadimkantorov changed the title Support bool input tensors for argmax / argmin and other functions Support bool input tensors for argmax / argmin / sort / topk and other functions Nov 24, 2021
@drisspg
Copy link
Contributor
drisspg commented Jun 7, 2023

Plus one I think this would be good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Not as big of a feature, but technically not a bug. Should be easy to fix module: reductions triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
0