OneHotArrays.jl icon indicating copy to clipboard operation
OneHotArrays.jl copied to clipboard

Reduce hcat creates dense matrix

Open simonmandlik opened this issue 2 years ago • 1 comments

See here: https://github.com/FluxML/Flux.jl/issues/1596

simonmandlik avatar Jan 12 '23 16:01 simonmandlik

Existing methods are here, a specialisation for reduce(hcat, ... could be added:

https://github.com/FluxML/OneHotArrays.jl/blob/9c43cb75a334f63dafb75143bb8e8adb6289d3f0/src/array.jl#L112-L130

I suspect these methods could use some stress-testing & tidying, e.g. cat(ohm, ohm; dims=Val(2)) looks like it will be an error (instead of falling back).

And [edit] that reduce(vcat, ...; init) is a fallback method, not the fast reduce(vcat, xs::Vector) method. It should just be vcat(x, xs...) here.

mcabbott avatar Jan 12 '23 16:01 mcabbott