Skip to content

Commit 7f67033

Browse files
authored
Merge pull request #349 from JuliaGPU/tb/show_adapt
Simplify adapt calls when showing arrays.
2 parents 7f8410a + 2d2e897 commit 7f67033

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

Manifest.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
[[AbstractFFTs]]
44
deps = ["LinearAlgebra"]
5-
git-tree-sha1 = "8ed9de2f1b1a9b1dee48582ad477c6e67b83eb2c"
5+
git-tree-sha1 = "485ee0867925449198280d4af84bdb46a2a404d0"
66
uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c"
7-
version = "1.0.0"
7+
version = "1.0.1"
88

99
[[Adapt]]
1010
deps = ["LinearAlgebra"]
11-
git-tree-sha1 = "27edd95a09fd428113ca019c092e8aeca2eb1f2d"
11+
git-tree-sha1 = "f1b523983a58802c4695851926203b36e28f09db"
1212
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
13-
version = "3.0.0"
13+
version = "3.3.0"
1414

1515
[[Libdl]]
1616
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

src/host/abstractarray.jl

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,26 @@ function Serialization.deserialize(s::AbstractSerializer, ::Type{T}) where T <:
3939
T(A)
4040
end
4141

42-
## convert to CPU (keeping wrapper type)
42+
## showing
4343

4444
struct ToArray end
45-
46-
Adapt.adapt_storage(::ToArray, xs::AbstractArray) = convert(Array, xs)
47-
convert_to_cpu(xs) = adapt(ToArray(), xs)
48-
49-
## showing
45+
Adapt.adapt_storage(::ToArray, xs::AbstractGPUArray) = convert(Array, xs)
5046

5147
# display
5248
Base.print_array(io::IO, X::AnyGPUArray) =
53-
Base.print_array(io, convert_to_cpu(X))
49+
Base.print_array(io, adapt(ToArray(), X))
5450

5551
# show
5652
Base._show_nonempty(io::IO, X::AnyGPUArray, prefix::String) =
57-
Base._show_nonempty(io, convert_to_cpu(X), prefix)
53+
Base._show_nonempty(io, adapt(ToArray(), X), prefix)
5854
Base._show_empty(io::IO, X::AnyGPUArray) =
59-
Base._show_empty(io, convert_to_cpu(X))
55+
Base._show_empty(io, adapt(ToArray(), X))
6056
Base.show_vector(io::IO, v::AnyGPUArray, args...) =
61-
Base.show_vector(io, convert_to_cpu(v), args...)
57+
Base.show_vector(io, adapt(ToArray(), v), args...)
6258

6359
## collect to CPU (discarding wrapper type)
6460

65-
collect_to_cpu(xs::AbstractArray) = collect(convert_to_cpu(xs))
61+
collect_to_cpu(xs::AbstractArray) = collect(adapt(ToArray(), xs))
6662
Base.collect(X::AnyGPUArray) = collect_to_cpu(X)
6763

6864

0 commit comments

Comments
 (0)