torch_cluster/sampler.py
raw| 1 | import torch |
| 2 | |
| 3 | |
| 4 | def neighbor_sampler(start: torch.Tensor, rowptr: torch.Tensor, size: float): |
| 5 | assert not start.is_cuda |
| 6 | |
| 7 | factor: float = -1. |
| 8 | count: int = -1 |
| 9 | if size <= 1: |
| 10 | factor = size |
| 11 | assert factor > 0 |
| 12 | else: |
| 13 | count = int(size) |
| 14 | |
| 15 | return torch.ops.torch_cluster.neighbor_sampler(start, rowptr, count, |
| 16 | factor) |