Passing a StaticArray to sum throws an error

Any idea why sum throws an error when given a StaticArray ? (I’m using Julia 1.5.3)

using StaticArrays
input = @SArray rand(2,2,2);
sum(input, dims=(1,2)) # throws error


ERROR: LoadError: MethodError: no method matching _mapfoldl(::typeof(identity), ::typeof(+), ::Tuple{Int64,Int64}, ::StaticArrays._InitialValue, ::Size{(2, 2, 2)}, ::SArray{Tuple{2,2,2},Float64,3,8})

I’m not sure why that doesn’t work, but

 sum(sum(input, dims=2), dims=1)

seems to.

1 Like

I opened an issue in their GitHub repo. Thanks for the workaround!