Skip to content

Setting a float type tensor to RandomPosterize() works against the error messages #9051

Closed
@hyperkai

Description

@hyperkai

🐛 Describe the bug

Setting a complex and bool type tensor to RandomPosterize() gets the error messages saying Number of value bits is only defined for integer dtypes as shown below:

from torchvision.transforms.v2 import RandomPosterize

rp = RandomPosterize(bits=1, p=1)
              # ↓↓↓↓↓↓↓↓↓↓
rp(torch.tensor([[5.+0.j]])) # Error

              # ↓↓↓↓↓↓↓↓
rp(torch.tensor([[True]])) # Error

TypeError: Number of value bits is only defined for integer dtypes, but got torch.complex64.

TypeError: Number of value bits is only defined for integer dtypes, but got torch.bool.

But setting a float type tensor to RandomPosterize() works against the error messages above as shown below:

from torchvision.transforms.v2 import RandomPosterize

rp = RandomPosterize(bits=1, p=1)
              # ↓↓↓↓↓↓
rp(torch.tensor([[5.]]))
# tensor([[0.5000]])

Versions

import torchvision

torchvision.__version__ # '0.20.1'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions