File: sampler.py

package info (click to toggle)
pytorch-cluster 1.6.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 648 kB
  • sloc: cpp: 2,076; python: 1,081; sh: 53; makefile: 8
file content (16 lines) | stat: -rw-r--r-- 404 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import torch


def neighbor_sampler(start: torch.Tensor, rowptr: torch.Tensor, size: float):
    assert not start.is_cuda

    factor: float = -1.
    count: int = -1
    if size <= 1:
        factor = size
        assert factor > 0
    else:
        count = int(size)

    return torch.ops.torch_cluster.neighbor_sampler(start, rowptr, count,
                                                    factor)