sparse.h 3.6 KB
Newer Older
quyuanhao123's avatar
quyuanhao123 committed
1
2
#pragma once

limm's avatar
limm committed
3
4
#include "extensions.h"
#include "macros.h"
quyuanhao123's avatar
quyuanhao123 committed
5

limm's avatar
limm committed
6
7
namespace sparse {
SPARSE_API int64_t cuda_version() noexcept;
quyuanhao123's avatar
quyuanhao123 committed
8

limm's avatar
limm committed
9
10
11
12
namespace detail {
SPARSE_INLINE_VARIABLE int64_t _cuda_version = cuda_version();
} // namespace detail
} // namespace sparse
quyuanhao123's avatar
quyuanhao123 committed
13
14
15
16

SPARSE_API torch::Tensor ind2ptr(torch::Tensor ind, int64_t M);
SPARSE_API torch::Tensor ptr2ind(torch::Tensor ptr, int64_t E);

limm's avatar
limm committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
SPARSE_API torch::Tensor
partition(torch::Tensor rowptr, torch::Tensor col,
          torch::optional<torch::Tensor> optional_value, int64_t num_parts,
          bool recursive);

SPARSE_API torch::Tensor
partition2(torch::Tensor rowptr, torch::Tensor col,
           torch::optional<torch::Tensor> optional_value,
           torch::optional<torch::Tensor> optional_node_weight,
           int64_t num_parts, bool recursive);

SPARSE_API torch::Tensor
mt_partition(torch::Tensor rowptr, torch::Tensor col,
             torch::optional<torch::Tensor> optional_value,
             torch::optional<torch::Tensor> optional_node_weight,
             int64_t num_parts, bool recursive, int64_t num_workers);

quyuanhao123's avatar
quyuanhao123 committed
34
SPARSE_API std::tuple<torch::Tensor, torch::Tensor> relabel(torch::Tensor col,
limm's avatar
limm committed
35
                                                            torch::Tensor idx);
quyuanhao123's avatar
quyuanhao123 committed
36

limm's avatar
limm committed
37
38
SPARSE_API std::tuple<torch::Tensor, torch::Tensor,
                      torch::optional<torch::Tensor>, torch::Tensor>
quyuanhao123's avatar
quyuanhao123 committed
39
40
41
42
43
relabel_one_hop(torch::Tensor rowptr, torch::Tensor col,
                torch::optional<torch::Tensor> optional_value,
                torch::Tensor idx, bool bipartite);

SPARSE_API torch::Tensor random_walk(torch::Tensor rowptr, torch::Tensor col,
limm's avatar
limm committed
44
                                     torch::Tensor start, int64_t walk_length);
quyuanhao123's avatar
quyuanhao123 committed
45
46
47
48
49

SPARSE_API std::tuple<torch::Tensor, torch::Tensor, torch::Tensor>
subgraph(torch::Tensor idx, torch::Tensor rowptr, torch::Tensor row,
         torch::Tensor col);

limm's avatar
limm committed
50
51
SPARSE_API
std::tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor>
quyuanhao123's avatar
quyuanhao123 committed
52
53
54
55
sample_adj(torch::Tensor rowptr, torch::Tensor col, torch::Tensor idx,
           int64_t num_neighbors, bool replace);

SPARSE_API torch::Tensor spmm_sum(torch::optional<torch::Tensor> opt_row,
limm's avatar
limm committed
56
57
58
59
60
                                  torch::Tensor rowptr, torch::Tensor col,
                                  torch::optional<torch::Tensor> opt_value,
                                  torch::optional<torch::Tensor> opt_colptr,
                                  torch::optional<torch::Tensor> opt_csr2csc,
                                  torch::Tensor mat);
quyuanhao123's avatar
quyuanhao123 committed
61
62

SPARSE_API torch::Tensor spmm_mean(torch::optional<torch::Tensor> opt_row,
limm's avatar
limm committed
63
64
65
66
67
68
                                   torch::Tensor rowptr, torch::Tensor col,
                                   torch::optional<torch::Tensor> opt_value,
                                   torch::optional<torch::Tensor> opt_rowcount,
                                   torch::optional<torch::Tensor> opt_colptr,
                                   torch::optional<torch::Tensor> opt_csr2csc,
                                   torch::Tensor mat);
quyuanhao123's avatar
quyuanhao123 committed
69
70
71
72
73
74
75
76
77

SPARSE_API std::tuple<torch::Tensor, torch::Tensor>
spmm_min(torch::Tensor rowptr, torch::Tensor col,
         torch::optional<torch::Tensor> opt_value, torch::Tensor mat);

SPARSE_API std::tuple<torch::Tensor, torch::Tensor>
spmm_max(torch::Tensor rowptr, torch::Tensor col,
         torch::optional<torch::Tensor> opt_value, torch::Tensor mat);

limm's avatar
limm committed
78
79
SPARSE_API
std::tuple<torch::Tensor, torch::Tensor, torch::optional<torch::Tensor>>
quyuanhao123's avatar
quyuanhao123 committed
80
81
82
spspmm_sum(torch::Tensor rowptrA, torch::Tensor colA,
           torch::optional<torch::Tensor> optional_valueA,
           torch::Tensor rowptrB, torch::Tensor colB,
limm's avatar
limm committed
83
           torch::optional<torch::Tensor> optional_valueB, int64_t K);