Skip to content

squeeze'ing of all singleton dimensions? #382

Closed
@pmeier

Description

@pmeier

Currently the only valid inputs for the axis parameter of xp.squeeze() are an int or a tuple of them.

Both numpy and PyTorch (I have not looked at the other libraries) support calling squeeze without the axis parameter. In this case all singleton dimensions will be squeezed:

In [1]: import numpy as np
In [2]: a = np.empty((1, 2, 1, 3, 1, 4))
In [3]: a.squeeze().shape
Out[3]: (2, 3, 4)
In [4]: import torch
In [5]: torch.from_numpy(a).squeeze().shape
Out[5]: torch.Size([2, 3, 4])

Maybe we can add this to the spec?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionGeneral question.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions