Skip to content

Commit f08a059

Browse files
Added test for similar for COO and BSR with custom types/dims
1 parent 035b00b commit f08a059

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

lib/cusparse/test/construction.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,28 @@ if capability(device()) >= v"5.3"
8888
end
8989
end
9090
end
91+
92+
@testset "similar for COO and BSR with custom types/dims" begin
93+
row = CuVector{Cint}([1, 2, 3])
94+
col = CuVector{Cint}([1, 2, 3])
95+
val = CuVector{Float32}([1.0, 2.0, 3.0])
96+
coo_mat = CuSparseMatrixCOO(row, col, val, (3, 3))
97+
98+
coo_sim = similar(coo_mat, Float64, (3, 3))
99+
@test eltype(coo_sim) == Float64
100+
@test size(coo_sim) == (3, 3)
101+
@test typeof(coo_sim) <: CuSparseMatrixCOO
102+
103+
rowPtr = CuVector{Cint}([1, 2, 3])
104+
colVal = CuVector{Cint}([1, 2])
105+
valBSR = CuVector{Float32}([1.0, 2.0, 3.0, 4.0])
106+
bsr_mat = CuSparseMatrixBSR(rowPtr, colVal, valBSR, 2, 'R', 1, (4, 4))
107+
108+
bsr_sim = similar(bsr_mat, Float64, (4, 4))
109+
@test eltype(bsr_sim) == Float64
110+
@test size(bsr_sim) == (4, 4)
111+
@test typeof(bsr_sim) <: CuSparseMatrixBSR
112+
@test bsr_sim.blockDim == bsr_mat.blockDim
113+
end
114+
91115
end

0 commit comments

Comments
 (0)