-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Ambiguity in getindex
, and missing ==
definition?
#28
Comments
I think these signatures need to be made more specific to include GPUArray + Int + Vararg{Int} as a combo. |
I haven't investigated but those do look a bit non-standard, the usual form is |
This error also occurs when OneHotArrays is used with CUDA, not sure what the correct solution is julia> a = onehotbatch([1,2,3],1:4) |> gpu
4×3 OneHotMatrix(::CuArray{UInt32, 1, CUDA.Mem.DeviceBuffer}) with eltype Bool:
1 ⋅ ⋅
⋅ 1 ⋅
⋅ ⋅ 1
⋅ ⋅ ⋅
julia> eachslice(a;dims = 2)
3-element ColumnSlices{OneHotMatrix{UInt32, CuArray{UInt32, 1, CUDA.Mem.DeviceBuffer}}, Tuple{Base.OneTo{Int64}}, SubArray{Bool, 1, OneHotMatrix{UInt32, CuArray{UInt32, 1, CUDA.Mem.DeviceBuffer}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, false}}:
Error showing value of type ColumnSlices{OneHotMatrix{UInt32, CuArray{UInt32, 1, CUDA.Mem.DeviceBuffer}}, Tuple{Base.OneTo{Int64}}, SubArray{Bool, 1, OneHotMatrix{UInt32, CuArray{UInt32, 1, CUDA.Mem.DeviceBuffer}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, false}}:
ERROR: MethodError: getindex(::OneHotMatrix{UInt32, CuArray{UInt32, 1, CUDA.Mem.DeviceBuffer}}, ::Int64, ::Int64) is ambiguous.
Candidates:
getindex(x::OneHotArray{var"#s3", N, var"N+1", I} where {var"#s3", var"N+1", I<:Union{AbstractArray{var"#s3", N}, var"#s3"}}, i::Int64, I::Vararg{Int64, N}) where N
@ OneHotArrays ~/.julia/packages/OneHotArrays/n10pv/src/array.jl:65
getindex(x::OneHotArray{<:Any, N, <:Any, <:GPUArraysCore.AbstractGPUArray}, i::Int64, I::Vararg{Any, N}) where N
@ OneHotArrays ~/.julia/packages/OneHotArrays/n10pv/src/array.jl:71
Possible fix, define
getindex(::OneHotArray{var"#s3", N, <:Any, <:Union{…}} where var"#s3", ::Int64, ::Vararg{Int64, N}) where N
Stacktrace:
[1] isassigned(::OneHotMatrix{UInt32, CuArray{UInt32, 1, CUDA.Mem.DeviceBuffer}}, ::Int64, ::Int64)
@ Base ./multidimensional.jl:1578
[2] isassigned
@ ./subarray.jl:362 [inlined]
[3] show_delim_array(io::IOContext{…}, itr::SubArray{…}, op::Char, delim::String, cl::Char, delim_one::Bool, i1::Int64, l::Int64)
@ Base ./show.jl:1342
[4] show_delim_array
@ ./show.jl:1335 [inlined]
[5] show_vector(io::IOContext{IOBuffer}, v::SubArray{Bool, 1, OneHotMatrix{…}, Tuple{…}, false}, opn::Char, cls::Char)
@ Base ./arrayshow.jl:530
[6] show_vector
@ ./arrayshow.jl:515 [inlined]
[7] show(io::IOContext{IOBuffer}, X::SubArray{Bool, 1, OneHotMatrix{…}, Tuple{…}, false})
@ Base ./arrayshow.jl:486
[8] sprint(f::Function, args::SubArray{…}; context::IOContext{…}, sizehint::Int64)
@ Base ./strings/io.jl:112
[9] sprint
@ ./strings/io.jl:107 [inlined]
[10] alignment_from_show
@ ./show.jl:3003 [inlined]
[11] alignment(io::IOContext{Base.TTY}, x::SubArray{Bool, 1, OneHotMatrix{…}, Tuple{…}, false})
@ Base ./show.jl:3022
[12] _print_matrix(io::IOContext{…}, X::AbstractVecOrMat, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64, rowsA::UnitRange{…}, colsA::UnitRange{…})
@ Base ./arrayshow.jl:207
[13] print_matrix(io::IOContext{…}, X::ColumnSlices{…}, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64)
@ Base ./arrayshow.jl:171
[14] print_matrix
@ ./arrayshow.jl:171 [inlined]
[15] print_array
@ ./arrayshow.jl:358 [inlined]
[16] show(io::IOContext{Base.TTY}, ::MIME{Symbol("text/plain")}, X::ColumnSlices{OneHotMatrix{…}, Tuple{…}, SubArray{…}})
@ Base ./arrayshow.jl:399
Some type information was truncated. Use `show(err)` to see complete types.
|
A workaround is use julia> x = Matrix(onehotbatch([1,2], 1:3)) |> cu
3×2 CuArray{Bool, 2, CUDA.Mem.DeviceBuffer}:
1 0
0 1
0 0
julia> eachslice(x;dims=2)
2-element ColumnSlices{CuArray{Bool, 2, CUDA.Mem.DeviceBuffer}, Tuple{Base.OneTo{Int64}}, CuArray{Bool, 1, CUDA.Mem.DeviceBuffer}}:
Bool[1, 0, 0]
Bool[0, 1, 0] |
The following error showed up in #27:
The text was updated successfully, but these errors were encountered: