Jutho / Strided.jl

A Julia package for strided array views and efficient manipulations thereof
Other
150 stars 13 forks source link

Broadcast Strided calls fail with `Base.ReshpaedArray` #26

Closed kmp5VT closed 10 months ago

kmp5VT commented 10 months ago

Hi I am trying to use strided on a Base.ReshapedArray and am returned a StackOverflow here are some examples

y = reshape(randn(elt, 8)', 2, 4)
x = Base.ReshapedArray(randn(elt, 8, 8)'[1:8], (2, 4), ())
y .= y .* x
# works 
@strided x .= x .* x

# stack overflow
@strided y .= y .* x
@strided x .= x .* y
@strided y .= y .* y

I was able to get some stacktrace regarding where the stack overflow is happening see the following

[1] sreshape(a::LinearAlgebra.Adjoint{Float32, StridedViews.StridedView{Float32, 1, Vector{Float32}, typeof(identity)}}, newsize::Tuple{Int64, Int64}) (repeats 42823 times)
      @ StridedViews ~/.julia/packages/StridedViews/bIjcq/src/stridedview.jl:172
    [2] StridedViews.StridedView(a::Base.ReshapedArray{Float32, 2, LinearAlgebra.Adjoint{Float32, Vector{Float32}}, Tuple{}})
      @ StridedViews ~/.julia/packages/StridedViews/bIjcq/src/stridedview.jl:50
    [3] maybestrided(A::Base.ReshapedArray{Float32, 2, LinearAlgebra.Adjoint{Float32, Vector{Float32}}, Tuple{}})
      @ Strided ~/.julia/packages/Strided/l1vm3/src/macros.jl:32
kmp5VT commented 10 months ago

This issue appears to be solved with https://github.com/Jutho/StridedViews.jl/pull/5