|
52 | 52 |
|
53 | 53 | ## showing
|
54 | 54 |
|
55 |
| -for (AT, f) in |
56 |
| - (GPUArray => Array, |
57 |
| - SubArray{<:Any,<:Any,<:GPUArray} => x->SubArray(Array(parent(x)), parentindices(x)), |
58 |
| - LinearAlgebra.Adjoint{<:Any,<:GPUArray} => x->LinearAlgebra.adjoint(Array(parent(x))), |
59 |
| - LinearAlgebra.Transpose{<:Any,<:GPUArray} => x->LinearAlgebra.transpose(Array(parent(x))), |
60 |
| - LinearAlgebra.LowerTriangular{<:Any,<:GPUArray} => x->LinearAlgebra.LowerTriangular(Array(x.data)), |
61 |
| - LinearAlgebra.UnitLowerTriangular{<:Any,<:GPUArray} => x->LinearAlgebra.UnitLowerTriangular(Array(x.data)), |
62 |
| - LinearAlgebra.UpperTriangular{<:Any,<:GPUArray} => x->LinearAlgebra.UpperTriangular(Array(x.data)), |
63 |
| - LinearAlgebra.UnitUpperTriangular{<:Any,<:GPUArray} => x->LinearAlgebra.UnitUpperTriangular(Array(x.data)) |
64 |
| - ) |
65 |
| - @eval begin |
66 |
| - # for display |
67 |
| - Base.print_array(io::IO, X::$AT) = |
68 |
| - Base.print_array(io,$f(X)) |
69 |
| - |
70 |
| - # for show |
71 |
| - Base._show_nonempty(io::IO, X::$AT, prefix::String) = |
72 |
| - Base._show_nonempty(io,$f(X),prefix) |
73 |
| - Base._show_empty(io::IO, X::$AT) = |
74 |
| - Base._show_empty(io,$f(X)) |
75 |
| - Base.show_vector(io::IO, v::$AT, args...) = |
76 |
| - Base.show_vector(io,$f(v),args...) |
77 |
| - end |
| 55 | +for (W, ctor) in (:AT => (A,mut)->mut(A), Adapt.wrappers...) |
| 56 | + @eval begin |
| 57 | + # display |
| 58 | + Base.print_array(io::IO, X::$W where {AT <: GPUArray}) = Base.print_array(io, $ctor(X, Array)) |
| 59 | + |
| 60 | + # show |
| 61 | + Base._show_nonempty(io::IO, X::$W where {AT <: GPUArray}, prefix::String) = |
| 62 | + Base._show_nonempty(io, $ctor(X, Array), prefix) |
| 63 | + Base._show_empty(io::IO, X::$W where {AT <: GPUArray}) = |
| 64 | + Base._show_empty(io, $ctor(X, Array)) |
| 65 | + Base.show_vector(io::IO, v::$W where {AT <: GPUArray}, args...) = |
| 66 | + Base.show_vector(io, $ctor(v, Array), args...) |
| 67 | + end |
78 | 68 | end
|
79 | 69 |
|
80 | 70 | # memory operations
|
|
0 commit comments