Skip to content
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

scalar indexing when showing OneHot gpu #1532

Closed
CarloLucibello opened this issue Mar 10, 2021 · 2 comments · Fixed by #1534
Closed

scalar indexing when showing OneHot gpu #1532

CarloLucibello opened this issue Mar 10, 2021 · 2 comments · Fixed by #1534

Comments

@CarloLucibello
Copy link
Member

I don't think this is supposed to happen, right @darsnack?

julia> using Flux, CUDA

julia> y = Flux.onehotbatch(rand(1:2, 5), 1:2)
2×5 Flux.OneHotArray{UInt32, 2, 1, 2, Vector{UInt32}}:
 1  0  1  1  0
 0  1  0  0  1


ulia> CUDA.allowscalar(true)

julia> y |> gpu
2×5 Flux.OneHotArray{UInt32, 2, 1, 2, CuArray{UInt32, 1}}:
┌ Warning: Performing scalar operations on GPU arrays: This is very slow, consider disallowing these operations with `allowscalar(false)`
└ @ GPUArrays ~/.julia/packages/GPUArrays/WV76E/src/host/indexing.jl:43
 1  0  1  1  0
 0  1  0  0  1

julia> CUDA.allowscalar(false)

julia> y |> gpu
2×5 Flux.OneHotArray{UInt32, 2, 1, 2, CuArray{UInt32, 1}}:
Error showing value of type Flux.OneHotArray{UInt32, 2, 1, 2, CuArray{UInt32, 1}}:
ERROR: scalar getindex is disallowed
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] assertscalar(op::String)
    @ GPUArrays ~/.julia/packages/GPUArrays/WV76E/src/host/indexing.jl:41
  [3] getindex
    @ ~/.julia/packages/GPUArrays/WV76E/src/host/indexing.jl:96 [inlined]
  [4] getindex
    @ ~/.julia/packages/Flux/zDU3v/src/onehot.jl:37 [inlined]
  [5] isassigned(::Flux.OneHotArray{UInt32, 2, 1, 2, CuArray{UInt32, 1}}, ::Int64, ::Int64)
    @ Base ./abstractarray.jl:507
  [6] alignment(io::IOContext{Base.TTY}, X::Flux.OneHotArray{UInt32, 2, 1, 2, CuArray{UInt32, 1}}, rows::UnitRange{Int64}, cols::UnitRange{Int64}, cols_if_complete::Int64, cols_otherwise::Int64, sep::Int64)
    @ Base ./arrayshow.jl:67
  [7] _print_matrix(io::IOContext{Base.TTY}, X::AbstractVecOrMat{T} where T, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64, rowsA::UnitRange{Int64}, colsA::UnitRange{Int64})
    @ Base ./arrayshow.jl:201
  [8] #invokelatest#2
    @ ./essentials.jl:707 [inlined]
  [9] invokelatest
    @ ./essentials.jl:706 [inlined]
 [10] print_matrix
    @ ./arrayshow.jl:170 [inlined]
 [11] print_array
    @ ./arrayshow.jl:327 [inlined]
 [12] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol("text/plain")}, X::Flux.OneHotArray{UInt32, 2, 1, 2, CuArray{UInt32, 1}})
    @ Base ./arrayshow.jl:368
 [13] (::REPL.var"#38#39"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:220
 [14] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:462
 [15] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:213
 [16] display(d::REPL.REPLDisplay, x::Any)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:225
 [17] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:328
 [18] #15
    @ ~/.julia/packages/Media/ItEPc/src/compat.jl:28 [inlined]
 [19] hookless(f::Media.var"#15#16"{Flux.OneHotArray{UInt32, 2, 1, 2, CuArray{UInt32, 1}}})
    @ Media ~/.julia/packages/Media/ItEPc/src/compat.jl:14
 [20] render
    @ ~/.julia/packages/Media/ItEPc/src/compat.jl:27 [inlined]
 [21] render(x::Flux.OneHotArray{UInt32, 2, 1, 2, CuArray{UInt32, 1}})
    @ Media ~/.julia/packages/Media/ItEPc/src/system.jl:160
 [22] display(#unused#::Media.DisplayHook, x::Flux.OneHotArray{UInt32, 2, 1, 2, CuArray{UInt32, 1}})
    @ Media ~/.julia/packages/Media/ItEPc/src/compat.jl:9
 [23] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:328
 [24] #invokelatest#2
    @ ./essentials.jl:707 [inlined]
 [25] invokelatest
    @ ./essentials.jl:706 [inlined]
 [26] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:247
 [27] (::REPL.var"#40#41"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:231
 [28] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:462
 [29] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:229
 [30] (::REPL.var"#do_respond#61"{Bool, Bool, REPL.var"#72#82"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:798
 [31] #invokelatest#2
    @ ./essentials.jl:707 [inlined]
 [32] invokelatest
    @ ./essentials.jl:706 [inlined]
 [33] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2441
 [34] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:1126
 [35] (::REPL.var"#44#49"{REPL.LineEditREPL, REPL.REPLBackendRef})()
@CarloLucibello
Copy link
Member Author

sorry my bad, this is due to the show, I think already made this mistake in the past. Can we fix the show? CuArray don't have this problem.

@CarloLucibello CarloLucibello changed the title scalar indexing when moving OneHot to gpu scalar indexing when showing OneHot gpu Mar 10, 2021
@darsnack
Copy link
Member

Yeah see #1494. It's actually an easy fix now that I think about it. Will get to it later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants