Skip to content

[functional] torch.unique not implemented for booleans #27691

@frgfm

Description

@frgfm

🐛 Bug

The torch.unique function is not implemented for torch.bool dtype.

To Reproduce

Steps to reproduce the behavior:

import torch
u1 = torch.unique(torch.rand(3,3), sorted=False)
u2 = torch.unique((10 * torch.rand(3,3)).round().to(dtype=torch.int), sorted=False)
u3 = torch.unique(torch.rand(3,3).round().to(dtype=torch.bool), sorted=False)

which produces

RuntimeError: "unique" not implemented for 'Bool'

Expected behavior

I understand the switch from torch.uint8 to torch.bool is fairly recent and that torch.unique does not seem very useful on booleans, but the feature is very useful when specifying the dim argument (torch.unique on boolean sequences for instance).

Environment

  • PyTorch Version: 1.2.0
  • OS: Ubuntu 18.04.3 LTS
  • How you installed PyTorch: conda
  • Python version: 3.7
  • CUDA/cuDNN version: CUDA 10.1.168 (cuDNN 7.6.2)
  • GPU models and configuration: GeForce GTX 1050 (driver: 430.50)

cc @ezyang @gchanan @zou3519 @jerryzh168 @izdeby

Metadata

Metadata

Assignees

Labels

high prioritymodule: boolean tensormodule: regressionIt used to work, and now it doesn'ttriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions