JuliaGraphs / GraphNeuralNetworks.jl

Graph Neural Networks in Julia
https://juliagraphs.org/GraphNeuralNetworks.jl/graphneuralnetworks/
MIT License
229 stars 45 forks source link

Missing bounds checking when working on GPU #181

Closed YichengDWu closed 2 years ago

YichengDWu commented 2 years ago

Related to https://github.com/FluxML/NNlib.jl/issues/411

using GraphNeuralNetworks
using CUDA
using Flux: gpu
g = rand_graph(10, 30) |> gpu
g = add_edges(g,[10],[10])
x = CUDA.rand(3, 9) #9<10!
apply_edges((xi, xj, e) -> xi .+ xj, g, xi=x, xj=x)

This won't throw an error. Maybe we can add

@assert size(xi)[end]==size(xj)[end]==g.num_nodes

inside apply_edges

YichengDWu commented 2 years ago

Even if we have bounds checking we should still add this line of code since we also don't want size(x)[end]>g.num_nodes. It just doesn't make sense.