Skip to content

[ux] Proposal to have t() === transpose(-1, -2), since batches are very frequent #51280

@vadimkantorov

Description

@vadimkantorov

In PyTorch usecases we almost always work with batches of matrices, and the convenience method t() breaks because it wants <= 2 dimensions. Since this is so common, I propose to relax constraints of t() and make it equivalent to transpose(-1, -2) for all input shapes.

This could have been discussed and decided before, but I could not find the issue...

torch.rand(3, 4, 5).t() # RuntimeError: t() expects a tensor with <= 2 dimensions, but self is 3D

torch.rand(3, 4, 5).transpose(-1, -2) # works

cc @mruberry @rgommers @heitorschueroff

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: numpyRelated to numpy support, and also numpy compatibility of our operatorsmodule: uxtriagedThis 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