Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/layers/conv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,15 @@ function (ggc::GatedGraphConv)(fg::FeaturedGraph, H::AbstractMatrix{S}) where {T
@assert (m <= ggc.out_ch) "number of input features must less or equals to output features."
adj = adjacency_list(fg)
if m < ggc.out_ch
Hpad = similar(H, S, ggc.out_ch - m, n)
H = vcat(H, fill!(Hpad, 0))
Hpad = Zygote.ignore() do
fill!(similar(H, S, ggc.out_ch - m, n), 0)
end
H = vcat(H, Hpad)
end
for i = 1:ggc.num_layers
M = view(ggc.weight, :, :, i) * H
_, M = propagate(ggc, adj, Fill(0.f0, 0, ne(fg)), M, +)
H, _ = ggc.gru(H, M) # BUG: FluxML/Flux.jl#1381
H, _ = ggc.gru(H, M)
end
H
end
Expand Down
14 changes: 7 additions & 7 deletions test/layers/conv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fg_single_vertex = FeaturedGraph(adj_single_vertex)
@test size(node_feature(fgt_)) == (out_channel, N)

g = Zygote.gradient(x -> sum(node_feature(gc(x))), fg)[1]
@test size(g[].nf) == size(X)
@test size(g.nf) == size(X)

g = Zygote.gradient(model -> sum(node_feature(model(fg))), gc)[1]
@test size(g.weight) == size(gc.weight)
Expand Down Expand Up @@ -118,7 +118,7 @@ fg_single_vertex = FeaturedGraph(adj_single_vertex)
@test size(node_feature(fgt_)) == (out_channel, N)

g = Zygote.gradient(x -> sum(node_feature(cc(x))), fg)[1]
@test size(g[].nf) == size(X)
@test size(g.nf) == size(X)

g = Zygote.gradient(model -> sum(node_feature(model(fg))), cc)[1]
@test size(g.weight) == size(cc.weight)
Expand Down Expand Up @@ -174,7 +174,7 @@ fg_single_vertex = FeaturedGraph(adj_single_vertex)
@test size(node_feature(fgt_)) == (out_channel, N)

g = Zygote.gradient(x -> sum(node_feature(gc(x))), fg)[1]
@test size(g[].nf) == size(X)
@test size(g.nf) == size(X)

g = Zygote.gradient(model -> sum(node_feature(model(fg))), gc)[1]
@test size(g.weight1) == size(gc.weight1)
Expand Down Expand Up @@ -245,7 +245,7 @@ fg_single_vertex = FeaturedGraph(adj_single_vertex)
@test size(node_feature(fgt_)) == (concat ? (out_channel*heads, N) : (out_channel, N))

g = Zygote.gradient(x -> sum(node_feature(gat(x))), fg_gat)[1]
@test size(g[].nf) == size(X)
@test size(g.nf) == size(X)

g = Zygote.gradient(model -> sum(node_feature(model(fg_gat))), gat)[1]
@test size(g.weight) == size(gat.weight)
Expand Down Expand Up @@ -299,7 +299,7 @@ fg_single_vertex = FeaturedGraph(adj_single_vertex)
@test size(node_feature(fgt_)) == (out_channel, N)

g = Zygote.gradient(x -> sum(node_feature(ggc(x))), fg)[1]
@test size(g[].nf) == size(X)
@test size(g.nf) == size(X)

g = Zygote.gradient(model -> sum(node_feature(model(fg))), ggc)[1]
@test size(g.weight) == size(ggc.weight)
Expand Down Expand Up @@ -342,7 +342,7 @@ fg_single_vertex = FeaturedGraph(adj_single_vertex)
@test size(node_feature(fgt_)) == (out_channel, N)

g = Zygote.gradient(x -> sum(node_feature(ec(x))), fg)[1]
@test size(g[].nf) == size(X)
@test size(g.nf) == size(X)

g = Zygote.gradient(model -> sum(node_feature(model(fg))), ec)[1]
@test size(g.nn.weight) == size(ec.nn.weight)
Expand Down Expand Up @@ -371,7 +371,7 @@ fg_single_vertex = FeaturedGraph(adj_single_vertex)

g = Zygote.gradient(x -> sum(node_feature(gc(x))),
FeaturedGraph(adj, nf=X))[1]
@test size(g.x.nf) == size(X)
@test size(g.nf) == size(X)

g = Zygote.gradient(model -> sum(node_feature(model(FeaturedGraph(adj, nf=X)))),
gc)[1]
Expand Down
8 changes: 3 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using GeometricFlux
using GeometricFlux.Datasets
using CUDA
using Flux
using Flux: @functor
using FillArrays
using GraphSignals
using LightGraphs: SimpleGraph, SimpleDiGraph, add_edge!, nv, ne
using LinearAlgebra
using NNlib
using NNlib, NNlibCUDA
using SparseArrays: SparseMatrixCSC
using Statistics: mean
using Zygote
Expand All @@ -26,10 +27,7 @@ tests = [
"models",
]

if Flux.use_cuda[]
using CUDA
using Flux: gpu
using NNlibCUDA
if CUDA.functional()
append!(tests, cuda_tests)
else
@warn "CUDA unavailable, not testing GPU support"
Expand Down