rw.py 318 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
4
5
6
7
8
9
10
11
import torch
from torch_sparse.tensor import SparseTensor


def random_walk(src: SparseTensor, start: torch.Tensor,
                walk_length: int) -> torch.Tensor:
    rowptr, col, _ = src.csr()
    return torch.ops.torch_sparse.random_walk(rowptr, col, start, walk_length)


SparseTensor.random_walk = random_walk