Skip to content

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

@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

Labels

bugSomething isn't workingserviceFixing this counts towards service requirements

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions