in benchmarks/api/bench_sampler.py [0:0]
def test_glt_ogbnproducts(mode='GPU'):
if mode == 'GPU':
graph_mode = 'CUDA'
else:
graph_mode = 'ZERO_COPY'
root = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))),
'..', 'data', 'products')
dataset = PygNodePropPredDataset('ogbn-products', root)
train_idx = dataset.get_idx_split()["train"]
train_loader = torch.utils.data.DataLoader(train_idx,
batch_size=1024,
pin_memory=True,
shuffle=True)
csr_topo = glt.data.Topology(dataset[0].edge_index)
g = glt.data.Graph(csr_topo, graph_mode, device=0)
device = torch.device('cuda:0')
sampler = glt.sampler.NeighborSampler(g, [15, 10, 5], device=device)
total_time = 0
sampled_edges = 0
for seeds in train_loader:
seeds = seeds.to(0)
torch.cuda.synchronize()
start = time.time()
row = sampler.sample_from_nodes(seeds).row
torch.cuda.synchronize()
total_time += time.time() - start
sampled_edges += row.shape[0]
print('Sampled Edges per secs: {} M'.format(sampled_edges / total_time / 1000000))