-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error transforming a reshaped 0-dimentional GPU array to a CPU array #494
Comments
Issue in Base: julia> a = zeros()
0-dimensional Array{Float64,0}:
0.0
julia> b = Base.ReshapedArray(a, (), ())
0-dimensional reshape(::Array{Float64,0}, ) with eltype Float64:
0.0
julia> pointer(b, 1)
ERROR: ArgumentError: reducing over an empty collection is not allowed
Stacktrace:
[1] _empty_reduce_error() at ./reduce.jl:299
[2] reduce_empty(::typeof(Base.add_sum), ::Type{Union{}}) at ./reduce.jl:319
[3] reduce_empty(::Base.BottomRF{typeof(Base.add_sum)}, ::Type{Union{}}) at ./reduce.jl:328
[4] reduce_empty_iter at ./reduce.jl:355 [inlined]
[5] reduce_empty_iter at ./reduce.jl:354 [inlined]
[6] foldl_impl(::Base.BottomRF{typeof(Base.add_sum)}, ::NamedTuple{(),Tuple{}}, ::Tuple{}) at ./reduce.jl:49
[7] mapfoldl_impl(::typeof(identity), ::typeof(Base.add_sum), ::NamedTuple{(),Tuple{}}, ::Tuple{}) at ./reduce.jl:44
[8] mapfoldl(::Function, ::Function, ::Tuple{}; kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at ./reduce.jl:160
[9] mapfoldl at ./reduce.jl:160 [inlined]
[10] #mapreduce#208 at ./reduce.jl:287 [inlined]
[11] mapreduce(::Function, ::Function, ::Tuple{}) at ./reduce.jl:287
[12] sum(::Function, ::Tuple{}) at ./reduce.jl:494
[13] sum(::Tuple{}) at ./reduce.jl:511
[14] _memory_offset(::Base.ReshapedArray{Float64,0,Array{Float64,0},Tuple{}}, ::Int64) at ./abstractarray.jl:1016
[15] pointer(::Base.ReshapedArray{Float64,0,Array{Float64,0},Tuple{}}, ::Int64) at ./abstractarray.jl:1009
[16] top-level scope at REPL[15]:1 I'm considering reverting the SubArray/ReshapedArray/ReinterpretArray change, as it has caused several issues. |
Great, helps a lot to OMEinsum.jl . |
Could you elaborate? Can't you run into these wrappers with Base arrays too? Array is special-cased to return a regular Array again, but with other inputs you'd still see SubArray/ReinterpretArray/ReshapeArray (and the DenseCuArray etc unions should take care of those). |
Currently, It is mainly about dispatch, output type stability et. al. I have fixed the issue of dispatch in this PR but not yet tested the performance, I will return to this issue after benchmarking (when I have time). |
#498, feedback appreciated. |
I can fix it by dispatching the 0-dimentional reshaped array function, but I think you may know how to fix this issue better.
The text was updated successfully, but these errors were encountered: