Skip to content

reshape fails when expanding/reducing dims for one-element scalars/tensors #743

Open
@mtsokol

Description

@mtsokol

Hi @willow-ahrens,

The pydata/sparse#865 is almost ready - we only have a few edge cases for jl.reshape function missing.

ATM reshape doesn't cover cases where input is a scalar and reshape is meant to expand dims. Likewise, for one-element tensors when dropping dims (and hypothesis in Array API tests came across these cases).

Here's a script that reproduces it:

using Finch

T1 = swizzle(Tensor(Element(0, 0)))
T2 = swizzle(Tensor([0]), 1)

reshape(T1)
reshape(T1, 1)  # fails
reshape(T1, 1, 1)  # fails

reshape(T2, 1)
reshape(T2, 1, 1)
reshape(T2)  # fails

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions