Skip to content

Commit

Permalink
Make sparse version work without cuda.
Browse files Browse the repository at this point in the history
  • Loading branch information
pbloem committed Jun 4, 2019
1 parent dc0be22 commit a96fc3c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def __init__(self, in_features, out_features, dropout, alpha, concat=True):
self.special_spmm = SpecialSpmm()

def forward(self, input, adj):
dv = 'cuda' if input.is_cuda else 'cpu'

N = input.size()[0]
edge = adj.nonzero().t()

Expand All @@ -112,7 +114,7 @@ def forward(self, input, adj):
assert not torch.isnan(edge_e).any()
# edge_e: E

e_rowsum = self.special_spmm(edge, edge_e, torch.Size([N, N]), torch.ones(size=(N,1)).cuda())
e_rowsum = self.special_spmm(edge, edge_e, torch.Size([N, N]), torch.ones(size=(N,1), device=dv))
# e_rowsum: N x 1

edge_e = self.dropout(edge_e)
Expand Down

0 comments on commit a96fc3c

Please sign in to comment.