Skip to content

Unify reshape routing to make extension easier #39123

@darsnack

Description

@darsnack

We ran into an issue trying to extend Base.reshape in FluxML/Flux.jl#1448. Ideally, someone should only have to overload

Base.reshape(x::MySpecialArray, dims::Dims)

to get insert their custom behavior. Currently, calls involving a single : bypass this method signature directly to the internal _reshape. I'd like to redefine this line to be:

reshape(parent::AbstractArray, dims::Tuple{Vararg{Union{Int,Colon}}}) = reshape(parent, _reshape_uncolon(parent, dims))

so that it routes through the signature above after the uncolon logic is applied. I see no real problems with this, but I wanted to create an issue before a PR to get told why I'm wrong.

Metadata

Metadata

Assignees

Labels

arrays[a, r, r, a, y, s]

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions