Unverified Commit f41934df authored by czkkkkkk's avatar czkkkkkk Committed by GitHub
Browse files

[Sparse] Add conversion between DGLGraph and SparseMatrix. (#5553)

parent e6226e82
......@@ -35,7 +35,7 @@ def _AXWb(A, X, W, b):
def test_graph_conv0(out_dim):
g = dgl.DGLGraph(nx.path_graph(3)).to(F.ctx())
ctx = F.ctx()
adj = g.adjacency_matrix(transpose=True, ctx=ctx)
adj = g.adj_external(transpose=True, ctx=ctx)
conv = nn.GraphConv(5, out_dim, norm="none", bias=True)
conv = conv.to(ctx)
......@@ -220,7 +220,7 @@ def test_tagconv(out_dim):
g = dgl.DGLGraph(nx.path_graph(3))
g = g.to(F.ctx())
ctx = F.ctx()
adj = g.adjacency_matrix(transpose=True, ctx=ctx)
adj = g.adj_external(transpose=True, ctx=ctx)
norm = th.pow(g.in_degrees().float(), -0.5)
conv = nn.TAGConv(5, out_dim, bias=True)
......@@ -1140,7 +1140,7 @@ def test_dense_graph_conv(norm_type, g, idtype, out_dim):
g = g.astype(idtype).to(F.ctx())
ctx = F.ctx()
# TODO(minjie): enable the following option after #1385
adj = g.adjacency_matrix(transpose=True, ctx=ctx).to_dense()
adj = g.adj_external(transpose=True, ctx=ctx).to_dense()
conv = nn.GraphConv(5, out_dim, norm=norm_type, bias=True)
dense_conv = nn.DenseGraphConv(5, out_dim, norm=norm_type, bias=True)
dense_conv.weight.data = conv.weight.data
......@@ -1159,7 +1159,7 @@ def test_dense_graph_conv(norm_type, g, idtype, out_dim):
def test_dense_sage_conv(g, idtype, out_dim):
g = g.astype(idtype).to(F.ctx())
ctx = F.ctx()
adj = g.adjacency_matrix(transpose=True, ctx=ctx).to_dense()
adj = g.adj_external(transpose=True, ctx=ctx).to_dense()
sage = nn.SAGEConv(5, out_dim, "gcn")
dense_sage = nn.DenseSAGEConv(5, out_dim)
dense_sage.fc.weight.data = sage.fc_neigh.weight.data
......@@ -1258,7 +1258,7 @@ def test_dense_cheb_conv(out_dim):
ctx = F.ctx()
g = dgl.DGLGraph(sp.sparse.random(100, 100, density=0.1), readonly=True)
g = g.to(F.ctx())
adj = g.adjacency_matrix(transpose=True, ctx=ctx).to_dense()
adj = g.adj_external(transpose=True, ctx=ctx).to_dense()
cheb = nn.ChebConv(5, out_dim, k, None)
dense_cheb = nn.DenseChebConv(5, out_dim, k)
# for i in range(len(cheb.fc)):
......
......@@ -31,7 +31,7 @@ def test_graph_conv(out_dim):
g = dgl.DGLGraph(nx.path_graph(3)).to(F.ctx())
ctx = F.ctx()
adj = tf.sparse.to_dense(
tf.sparse.reorder(g.adjacency_matrix(transpose=True, ctx=ctx))
tf.sparse.reorder(g.adj_external(transpose=True, ctx=ctx))
)
conv = nn.GraphConv(5, out_dim, norm="none", bias=True)
......@@ -610,7 +610,7 @@ def test_dense_cheb_conv(out_dim):
g = g.to(ctx)
adj = tf.sparse.to_dense(
tf.sparse.reorder(g.adjacency_matrix(transpose=True, ctx=ctx))
tf.sparse.reorder(g.adj_external(transpose=True, ctx=ctx))
)
cheb = nn.ChebConv(5, out_dim, k, None, bias=True)
dense_cheb = nn.DenseChebConv(5, out_dim, k, bias=True)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment