-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4deb30e
commit b5512db
Showing
4 changed files
with
115 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
in_channel = 10 | ||
out_channel = 5 | ||
N = 6 | ||
T = Float32 | ||
adj = [0 1 0 0 0 0 | ||
1 0 0 1 1 1 | ||
0 0 0 0 0 1 | ||
0 1 0 0 1 0 | ||
0 1 0 1 0 1 | ||
0 1 1 0 1 0] | ||
@testset "cuda/msgpass" begin | ||
in_channel = 10 | ||
out_channel = 5 | ||
N = 6 | ||
T = Float32 | ||
adj = [0 1 0 0 0 0 | ||
1 0 0 1 1 1 | ||
0 0 0 0 0 1 | ||
0 1 0 0 1 0 | ||
0 1 0 1 0 1 | ||
0 1 1 0 1 0] | ||
|
||
struct NewCudaLayer | ||
weight | ||
end | ||
NewCudaLayer(m, n) = NewCudaLayer(randn(T, m,n)) | ||
@functor NewCudaLayer | ||
struct NewCudaLayer | ||
weight | ||
end | ||
NewCudaLayer(m, n) = NewCudaLayer(randn(T, m, n)) | ||
@functor NewCudaLayer | ||
|
||
(l::NewCudaLayer)(X) = GraphNeuralNetworks.propagate(l, X, +) | ||
GraphNeuralNetworks.message(n::NewCudaLayer, x_i, x_j, e_ij) = n.weight * x_j | ||
GraphNeuralNetworks.update(::NewCudaLayer, m, x) = m | ||
(l::NewCudaLayer)(g, X) = GraphNeuralNetworks.propagate(l, g, +, X) | ||
GraphNeuralNetworks.message(n::NewCudaLayer, x_i, x_j, e_ij) = n.weight * x_j | ||
GraphNeuralNetworks.update(::NewCudaLayer, x, m) = m | ||
|
||
X = rand(T, in_channel, N) |> gpu | ||
g = GNNGraph(adj, ndata=X, graph_type=GRAPH_T) | ||
l = NewCudaLayer(out_channel, in_channel) |> gpu | ||
X = rand(T, in_channel, N) |> gpu | ||
g = GNNGraph(adj, ndata=X, graph_type=GRAPH_T) | ||
l = NewCudaLayer(out_channel, in_channel) |> gpu | ||
|
||
@testset "cuda/msgpass" begin | ||
g_ = l(g) | ||
@test size(node_features(g_)) == (out_channel, N) | ||
end |
Oops, something went wrong.