Skip to content

Commit 3b7979a

Browse files
authored
Merge pull request #198 from JuliaGPU/tb/subarray
Use adapt to show SubArray indices.
2 parents 3a6c08b + a3cc3ec commit 3b7979a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/abstractarray.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,21 @@ end
5252

5353
## showing
5454

55+
Adapt.adapt_storage(::Type{<:Array}, xs::AbstractArray) = convert(Array, xs)
56+
cpu(xs) = adapt(Array, xs)
57+
5558
for (W, ctor) in (:AT => (A,mut)->mut(A), Adapt.wrappers...)
5659
@eval begin
5760
# display
58-
Base.print_array(io::IO, X::$W where {AT <: GPUArray}) = Base.print_array(io, $ctor(X, Array))
61+
Base.print_array(io::IO, X::$W where {AT <: GPUArray}) = Base.print_array(io, $ctor(X, cpu))
5962

6063
# show
6164
Base._show_nonempty(io::IO, X::$W where {AT <: GPUArray}, prefix::String) =
62-
Base._show_nonempty(io, $ctor(X, Array), prefix)
65+
Base._show_nonempty(io, $ctor(X, cpu), prefix)
6366
Base._show_empty(io::IO, X::$W where {AT <: GPUArray}) =
64-
Base._show_empty(io, $ctor(X, Array))
67+
Base._show_empty(io, $ctor(X, cpu))
6568
Base.show_vector(io::IO, v::$W where {AT <: GPUArray}, args...) =
66-
Base.show_vector(io, $ctor(v, Array), args...)
69+
Base.show_vector(io, $ctor(v, cpu), args...)
6770
end
6871
end
6972

0 commit comments

Comments
 (0)