Skip to content

Commit 2e92a2d

Browse files
fix nnlibcudaext (#621)
* fix * fix nnlibcudaext * cleanup * test fmt * fix
1 parent 366bdb8 commit 2e92a2d

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

GNNGraphs/src/convert.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function to_dense(A::ADJMAT_T, T = nothing; dir = :out, num_nodes = nothing,
137137
A = T.(A)
138138
end
139139
if !weighted
140-
A = map(x -> ifelse(x > 0, T(1), T(0)), A)
140+
A = binarize(A, T)
141141
end
142142
return A, num_nodes, num_edges
143143
end

GNNGraphs/test/query.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,15 @@ end
272272

273273
@test gw == [1, 1, 1]
274274
end
275+
276+
@testset "fmt" begin
277+
Asparse = adjacency_matrix(g, weighted = false, fmt = :sparse)
278+
@test Asparse isa AbstractSparseMatrix
279+
Adense = adjacency_matrix(g, weighted = false, fmt = :dense)
280+
@test Adense isa AbstractMatrix
281+
@test !(Adense isa AbstractSparseMatrix)
282+
@test collect(Asparse) == Adense
283+
end
275284
end
276285

277286
@testset "khop_adj" begin

GNNlib/ext/GNNlibCUDAExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module GNNlibCUDAExt
33
using CUDA
44
using Random, Statistics, LinearAlgebra
55
using GNNlib: GNNlib, propagate, copy_xj, e_mul_xj, w_mul_xj
6-
using GNNGraphs: GNNGraph, COO_T, SPARSE_T, to_dense, to_sparse
6+
using GNNGraphs: GNNGraph, COO_T, SPARSE_T, to_dense, to_sparse, adjacency_matrix
77
using ChainRulesCore: @non_differentiable
88

99
const CUDA_COO_T = Tuple{T, T, V} where {T <: AnyCuArray{<:Integer}, V <: Union{Nothing, AnyCuArray}}

0 commit comments

Comments
 (0)