Skip to content

Commit 859abfd

Browse files
return dense adjmatrix sometimes
1 parent 7040206 commit 859abfd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/gnngraph.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const COO_T = Tuple{T, T, V} where {T <: AbstractVector, V}
99
const ADJLIST_T = AbstractVector{T} where T <: AbstractVector
1010
const ADJMAT_T = AbstractMatrix
1111
const SPARSE_T = AbstractSparseMatrix # subset of ADJMAT_T
12+
const CUMAT_T = Union{AnyCuMatrix, CUDA.CUSPARSE.CuSparseMatrix}
1213

1314
"""
1415
GNNGraph(data; [graph_type, ndata, edata, gdata, num_nodes, graph_indicator, dir])
@@ -349,9 +350,13 @@ end
349350

350351
# _eigmax(A) = eigmax(Symmetric(A)) # Doesn't work on sparse arrays
351352
function _eigmax(A)
352-
x0 = randn!(similar(A, float(eltype(A)), size(A, 1)))
353+
x0 = _rand_dense_vector(A)
353354
KrylovKit.eigsolve(Symmetric(A), x0, 1, :LR)[1][1] # also eigs(A, x0, nev, mode) available
354355
end
356+
357+
_rand_dense_vector(A::AbstractMatrix{T}) where T = randn(float(T), size(A, 1))
358+
_rand_dense_vector(A::CUMAT_T)= CUDA.randn(size(A, 1))
359+
355360
# Eigenvalues for cuarray don't seem to be well supported.
356361
# https://github.com/JuliaGPU/CUDA.jl/issues/154
357362
# https://discourse.julialang.org/t/cuda-eigenvalues-of-a-sparse-matrix/46851/5

0 commit comments

Comments
 (0)