JuliaGPU / CUDA.jl

CUDA programming in Julia.
https://juliagpu.org/cuda/
Other
1.2k stars 215 forks source link

CuArray type aliases are not printed compactly #1408

Open ToucheSir opened 2 years ago

ToucheSir commented 2 years ago

Is your feature request related to a problem? Please describe.

The aliases defined in https://github.com/JuliaGPU/CUDA.jl/blob/v3.8.2/src/array.jl#L120-L121 do not seem to be considered as aliases for display purposes.

julia> cu([1, 2, 3])
3-element CuArray{Int64, 1, CUDA.Mem.DeviceBuffer}:
 1
 2
 3

julia> CuVector([1, 2, 3])
3-element CuArray{Int64, 1, CUDA.Mem.DeviceBuffer}:
 1
 2
 3

julia> CuVector
CuArray{T, 1} where T

julia> Vector  # c.f.
Vector (alias for Array{T, 1} where T)

Describe the solution you'd like

julia> cu([1, 2, 3])
3-element CuVector{Int64, CUDA.Mem.DeviceBuffer}:
 1
 2
 3

julia> CuVector
CuVector (alias for CuArray{T, 1, B} where T, B)

# or

julia> cu([1, 2, 3])
3-element CuVector{Int64}:
 1
 2
 3

julia> CuVector
CuVector (alias for CuArray{T, 1, <:Any} where T)

Describe alternatives you've considered

The default expanded CuArray printing is workable, but can add quote a bit of noise to the display of nested struct types and stacktraces.

Additional context

I tried figuring out how to do this but couldn't make sense of how the alias resolution works :(

maleadt commented 2 years ago

https://github.com/JuliaGPU/CUDA.jl/blob/95eec21737c5058817fbb979fb879301a859553e/src/array.jl#L260-L261

maleadt commented 2 years ago

I think this is best fixed in Base.

ToucheSir commented 2 years ago

I see, do you know of a Base issue to follow? I found https://github.com/JuliaLang/julia/issues/41034 before filing this but was unsure if it was related.

maleadt commented 2 years ago

I'm not sure of an open issue, but it's this TODO that needs to be addressed: https://github.com/JuliaLang/julia/blob/6b29ebda35b6c844198c5d1533587711a6700df2/base/show.jl#L580-L582