Skip to content

RandomRotate(((90, 90)) produces Non-Contiguous Tensors #9378

@DimitrisMantas

Description

@DimitrisMantas

🐛 Describe the bug

I'm not sure if this is machine-specific, but I think the fast rotation implementation for 90-degree multiples (#8295) produces non-contiguous tensors:

x = torch.rand((1, 1, 512, 512))  # Binary Segmentation Target
print(x.is_contiguous())  # True

x = torch.rot90(x, k=1, dims=(1, 2))
print(x.is_contiguous())  # False

My understanding is that this happens because rot90 uses transpose internally, for which this behavior is already documented.

This is an issue because it slows down training due to cache misses and also makes certain subsequent operations such as views impossible. So we should either require the output to be contiguous or document this behavior and let users handle it.

Versions

0.25.0

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