@@ -35,6 +35,7 @@ blockdim = 5
35
35
@test nnz (d_x) == length (nonzeros (d_x))
36
36
x = sprand (m,n,0.2 )
37
37
d_x = CuSparseMatrixCSC (x)
38
+ @test CuSparseMatrixCSC (d_x) === d_x
38
39
@test length (d_x) == m* n
39
40
@test size (d_x) == (m,n)
40
41
@test size (d_x,1 ) == m
@@ -76,15 +77,22 @@ blockdim = 5
76
77
@test_throws ArgumentError copyto! (d_y,d_x)
77
78
d_y = CuSparseMatrixCSR (d_y)
78
79
d_x = CuSparseMatrixCSR (d_x)
80
+ @test CuSparseMatrixCSR (d_x) === d_x
81
+ @test length (d_x) == m* n
79
82
@test_throws ArgumentError copyto! (d_y,d_x)
80
83
CUDA. @allowscalar begin
81
84
for i in 1 : size (y, 1 )
82
85
@test d_y[i, :] ≈ y[i, :]
83
86
end
87
+ @test d_y[1 , 1 ] ≈ y[1 , 1 ]
84
88
end
85
89
d_y = CuSparseMatrixBSR (d_y, blockdim)
86
90
d_x = CuSparseMatrixBSR (d_x, blockdim)
91
+ @test CuSparseMatrixBSR (d_x) === d_x
87
92
@test_throws ArgumentError copyto! (d_y,d_x)
93
+ CUDA. @allowscalar begin
94
+ @test d_y[1 , 1 ] ≈ y[1 , 1 ]
95
+ end
88
96
x = sprand (m,0.2 )
89
97
d_x = CuSparseVector (x)
90
98
@test size (d_x, 1 ) == m
140
148
@test collect (d_x) == collect (x)
141
149
@test similar (d_x) isa CuSparseMatrixCSC{elty}
142
150
@test similar (d_x, Float32) isa CuSparseMatrixCSC{Float32}
151
+ @test similar (d_x, Float32, n, m) isa CuSparseMatrixCSC{Float32}
143
152
end
144
153
145
154
@testset " CSR" begin
148
157
@test collect (d_x) == collect (x)
149
158
@test similar (d_x) isa CuSparseMatrixCSR{elty}
150
159
@test similar (d_x, Float32) isa CuSparseMatrixCSR{Float32}
160
+ @test similar (d_x, Float32, n, m) isa CuSparseMatrixCSR{Float32}
151
161
end
152
162
153
163
@testset " BSR" begin
@@ -158,12 +168,13 @@ end
158
168
@test similar (d_x, Float32) isa CuSparseMatrixBSR{Float32}
159
169
end
160
170
161
- @testset " BSR " begin
171
+ @testset " COO " begin
162
172
x = sprand (elty,m,n, 0.2 )
163
173
d_x = CuSparseMatrixCOO (x)
164
174
@test collect (d_x) == collect (x)
165
175
@test similar (d_x) isa CuSparseMatrixCOO{elty}
166
176
@test similar (d_x, Float32) isa CuSparseMatrixCOO{Float32}
177
+ @test similar (d_x, Float32, n, m) isa CuSparseMatrixCOO{Float32}
167
178
end
168
179
end
169
180
0 commit comments