sparse.h 3.59 KB
Newer Older
rusty1s's avatar
rusty1s committed
1
2
#pragma once

3
#include <torch/library.h>
rusty1s's avatar
rusty1s committed
4

Daniel Falbel's avatar
Daniel Falbel committed
5
6
7
8
9
10
11
12
13
#ifdef _WIN32
#if defined(torchsparse_EXPORTS)
#define SPARSE_API __declspec(dllexport)
#else
#define SPARSE_API __declspec(dllimport)
#endif
#else
#define SPARSE_API
#endif
rusty1s's avatar
rusty1s committed
14
15


Daniel Falbel's avatar
Daniel Falbel committed
16
17
18
19
20
21
SPARSE_API int64_t cuda_version();

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

SPARSE_API torch::Tensor partition(torch::Tensor rowptr, torch::Tensor col,
rusty1s's avatar
rusty1s committed
22
23
24
                        torch::optional<torch::Tensor> optional_value,
                        int64_t num_parts, bool recursive);

Daniel Falbel's avatar
Daniel Falbel committed
25
SPARSE_API torch::Tensor partition2(torch::Tensor rowptr, torch::Tensor col,
26
27
28
29
                         torch::optional<torch::Tensor> optional_value,
                         torch::optional<torch::Tensor> optional_node_weight,
                         int64_t num_parts, bool recursive);

Daniel Falbel's avatar
Daniel Falbel committed
30
SPARSE_API torch::Tensor mt_partition(torch::Tensor rowptr, torch::Tensor col,
rusty1s's avatar
rusty1s committed
31
                           torch::optional<torch::Tensor> optional_value,
Daniel Falbel's avatar
Daniel Falbel committed
32
33
34
35
36
                           torch::optional<torch::Tensor> optional_node_weight,
                           int64_t num_parts, bool recursive,
                           int64_t num_workers);
 
SPARSE_API std::tuple<torch::Tensor, torch::Tensor> relabel(torch::Tensor col,
rusty1s's avatar
rusty1s committed
37
38
                                                 torch::Tensor idx);

Daniel Falbel's avatar
Daniel Falbel committed
39
SPARSE_API std::tuple<torch::Tensor, torch::Tensor, torch::optional<torch::Tensor>,
rusty1s's avatar
rusty1s committed
40
41
42
           torch::Tensor>
relabel_one_hop(torch::Tensor rowptr, torch::Tensor col,
                torch::optional<torch::Tensor> optional_value,
Daniel Falbel's avatar
Daniel Falbel committed
43
                torch::Tensor idx, bool bipartite);
rusty1s's avatar
rusty1s committed
44

Daniel Falbel's avatar
Daniel Falbel committed
45
SPARSE_API torch::Tensor random_walk(torch::Tensor rowptr, torch::Tensor col,
rusty1s's avatar
rusty1s committed
46
47
                          torch::Tensor start, int64_t walk_length);

Daniel Falbel's avatar
Daniel Falbel committed
48
SPARSE_API std::tuple<torch::Tensor, torch::Tensor, torch::Tensor>
rusty1s's avatar
rusty1s committed
49
50
51
subgraph(torch::Tensor idx, torch::Tensor rowptr, torch::Tensor row,
         torch::Tensor col);

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

Daniel Falbel's avatar
Daniel Falbel committed
56
SPARSE_API torch::Tensor spmm_sum(torch::optional<torch::Tensor> opt_row,
rusty1s's avatar
rusty1s committed
57
58
59
60
61
62
                       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);

Daniel Falbel's avatar
Daniel Falbel committed
63
SPARSE_API torch::Tensor spmm_mean(torch::optional<torch::Tensor> opt_row,
rusty1s's avatar
rusty1s committed
64
65
66
67
68
69
70
                        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);

Daniel Falbel's avatar
Daniel Falbel committed
71
SPARSE_API std::tuple<torch::Tensor, torch::Tensor>
rusty1s's avatar
rusty1s committed
72
73
74
spmm_min(torch::Tensor rowptr, torch::Tensor col,
         torch::optional<torch::Tensor> opt_value, torch::Tensor mat);

Daniel Falbel's avatar
Daniel Falbel committed
75
SPARSE_API std::tuple<torch::Tensor, torch::Tensor>
rusty1s's avatar
rusty1s committed
76
77
78
spmm_max(torch::Tensor rowptr, torch::Tensor col,
         torch::optional<torch::Tensor> opt_value, torch::Tensor mat);

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