Skip to content

Commit 9c0cfd2

Browse files
committed
Import CuArray showing tests.
1 parent 0ed6336 commit 9c0cfd2

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

src/abstractarray.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ struct LocalMemory{T} <: GPUArray{T, 1}
1616
LocalMemory{T}(x::Integer) where T = new{T}(x)
1717
end
1818

19-
############################################
20-
# serialization
19+
20+
# input/output
21+
22+
## serialization
23+
2124
import Serialization: AbstractSerializer, serialize, deserialize, serialize_type
2225

2326
function serialize(s::AbstractSerializer, t::T) where T <: GPUArray
@@ -53,6 +56,14 @@ function to_cartesian(A, indices::Tuple)
5356
CartesianIndices(start, stop)
5457
end
5558

59+
## showing
60+
61+
Base.print_array(io::IO, x::GPUArray) = Base.print_array(io, collect(x))
62+
Base.print_array(io::IO, x::LinearAlgebra.Adjoint{<:Any,<:GPUArray}) = Base.print_array(io, LinearAlgebra.adjoint(collect(x.parent)))
63+
Base.print_array(io::IO, x::LinearAlgebra.Transpose{<:Any,<:GPUArray}) = Base.print_array(io, LinearAlgebra.transpose(collect(x.parent)))
64+
65+
66+
# memory operations
5667

5768
## basic copy methods that dispatch to unsafe_copyto! for linear copies
5869

src/array.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ size(x::JLArray) = x.size
2828

2929
pointer(x::JLArray) = pointer(x.data)
3030

31-
32-
## I/O
33-
Base.print_array(io::IO, x::GPUArray) = Base.print_array(io, collect(x))B
34-
Base.print_array(io::IO, x::LinearAlgebra.Adjoint{<:Any,<:GPUArray}) = Base.print_array(io, LinearAlgebra.adjoint(collect(x.parent)))
35-
Base.print_array(io::IO, x::LinearAlgebra.Transpose{<:Any,<:GPUArray}) = Base.print_array(io, LinearAlgebra.transpose(collect(x.parent)))
36-
3731
## other
3832

3933
"""

src/testsuite.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ include("testsuite/base.jl")
4646
include("testsuite/indexing.jl")
4747
include("testsuite/vector.jl")
4848
include("testsuite/random.jl")
49+
include("testsuite/io.jl")
4950

5051
function supported_eltypes()
5152
(Float32, Float64, Int32, Int64, ComplexF32, ComplexF64)

src/testsuite/io.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function test_io(Typ)
2+
@testset "i/o" begin
3+
@testset "Showing" begin
4+
io = IOBuffer()
5+
A = Typ([1])
6+
7+
show(io, MIME("text/plain"), A)
8+
seekstart(io)
9+
@test String(take!(io)) == "1-element $Typ{Int64,1}:\n 1"
10+
11+
show(io, MIME("text/plain"), A')
12+
seekstart(io)
13+
@test String(take!(io)) == "1×1 LinearAlgebra.Adjoint{Int64,$Typ{Int64,1}}:\n 1"
14+
end
15+
end
16+
end

0 commit comments

Comments
 (0)