Skip to content

Easier way to create tensors with names #27175

@zou3519

Description

@zou3519

🚀 Feature

Right now, to create a tensor with names, we do

x = torch.randn(3, 3, 3, 3, names=('N', 'C', 'H', 'W'))

Typing the ' a lot is an inconvenience. It would be nice to explore one of the following APIs:

  1. x = torch.randn(N=3, C=3, H=3, W=3) (Python >= 3.6)
  2. x = torch.randn(torch.dims(N=3, C=3, H=3, W=3)) (Python >= 3.6)
  3. x = torch.randn(3, 3, 3, 3, names='N C H W')
  4. x = torch.randn(3, 3, 3, 3, names='NCHW') (number of characters must match number of dims)

Motivation

Type less, feel happier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNot as big of a feature, but technically not a bug. Should be easy to fixmodule: named tensorNamed tensor supporttriagedThis 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