MCPcopy
hub / github.com/dmlc/dgl / test_basics

Function test_basics

tests/python/pytorch/test_ffi-stream.py:45–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43 F._default_context_str == "cpu", reason="stream only runs on GPU."
44)
45def test_basics():
46 g = rand_graph(10, 20, device=F.cpu())
47 x = torch.ones(g.num_nodes(), 10)
48 result = OPS.copy_u_sum(g, x).to(F.ctx())
49
50 # launch on default stream used in DGL
51 xx = x.to(device=F.ctx())
52 gg = g.to(device=F.ctx())
53 OPS.copy_u_sum(gg, xx)
54 assert torch.equal(OPS.copy_u_sum(gg, xx), result)
55
56 # launch on new stream created via torch.cuda
57 s = torch.cuda.Stream(device=F.ctx())
58 with torch.cuda.stream(s):
59 xx = x.to(device=F.ctx(), non_blocking=True)
60 gg = g.to(device=F.ctx())
61 OPS.copy_u_sum(gg, xx)
62 s.synchronize()
63 assert torch.equal(OPS.copy_u_sum(gg, xx), result)
64
65
66@unittest.skipIf(

Callers 1

test_ffi-stream.pyFile · 0.85

Calls 5

rand_graphFunction · 0.90
cpuMethod · 0.45
num_nodesMethod · 0.45
toMethod · 0.45
ctxMethod · 0.45

Tested by

no test coverage detected