dmlc--dgl
3b0c0cec46
* enable sparse on windows and mac * that was stupid * let's see what's going on.. * [Sparse] Fix the import error on Mac OS. When using template functions that are defined in source files from DGL, the loader of MacOS somehow cannot find their definitions. This fix simply avoids depending on template functions from DGL headers. With this fix, the sparse tests all pass on the MAC environment. * ok this is the problem * make errors clearer * uh * test * Update __init__.py * disabling ddp on windows --------- Co-authored-by: czkkkkkk <zekucai@gmail.com>
21 行
520 B
Python
21 行
520 B
Python
import sys
|
|
|
|
import backend as F
|
|
import torch
|
|
|
|
from dgl.sparse import from_coo
|
|
|
|
|
|
def test_neg():
|
|
ctx = F.ctx()
|
|
row = torch.tensor([1, 1, 3]).to(ctx)
|
|
col = torch.tensor([1, 2, 3]).to(ctx)
|
|
val = torch.tensor([1.0, 1.0, 2.0]).to(ctx)
|
|
A = from_coo(row, col, val)
|
|
neg_A = -A
|
|
assert A.shape == neg_A.shape
|
|
assert A.nnz == neg_A.nnz
|
|
assert torch.allclose(-A.val, neg_A.val)
|
|
assert torch.allclose(torch.stack(A.coo()), torch.stack(neg_A.coo()))
|
|
assert A.val.device == neg_A.val.device
|