Skip to content

Commit 3bf43eb

Browse files
authored
Export symbols (#198)
* Mark exported symbols with `SPARSE_API` so they are available in the DLL on WIndows. * Export symbols by default in the Python library. * Sync headers with implementation. * Include the `SPARSE_API` macro. * Fix linting issue.
1 parent 8cc819d commit 3bf43eb

File tree

15 files changed

+61
-42
lines changed

15 files changed

+61
-42
lines changed

csrc/convert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ PyMODINIT_FUNC PyInit__convert_cpu(void) { return NULL; }
1919
#endif
2020
#endif
2121

22-
torch::Tensor ind2ptr(torch::Tensor ind, int64_t M) {
22+
SPARSE_API torch::Tensor ind2ptr(torch::Tensor ind, int64_t M) {
2323
if (ind.device().is_cuda()) {
2424
#ifdef WITH_CUDA
2525
return ind2ptr_cuda(ind, M);
@@ -31,7 +31,7 @@ torch::Tensor ind2ptr(torch::Tensor ind, int64_t M) {
3131
}
3232
}
3333

34-
torch::Tensor ptr2ind(torch::Tensor ptr, int64_t E) {
34+
SPARSE_API torch::Tensor ptr2ind(torch::Tensor ptr, int64_t E) {
3535
if (ptr.device().is_cuda()) {
3636
#ifdef WITH_CUDA
3737
return ptr2ind_cuda(ptr, E);

csrc/diag.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ PyMODINIT_FUNC PyInit__diag_cpu(void) { return NULL; }
1919
#endif
2020
#endif
2121

22-
torch::Tensor non_diag_mask(torch::Tensor row, torch::Tensor col, int64_t M,
22+
SPARSE_API torch::Tensor non_diag_mask(torch::Tensor row, torch::Tensor col, int64_t M,
2323
int64_t N, int64_t k) {
2424
if (row.device().is_cuda()) {
2525
#ifdef WITH_CUDA

csrc/ego_sample.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ PyMODINIT_FUNC PyInit__ego_sample_cpu(void) { return NULL; }
1616
#endif
1717

1818
// Returns `rowptr`, `col`, `n_id`, `e_id`, `ptr`, `root_n_id`
19-
std::tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor,
19+
SPARSE_API std::tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor,
2020
torch::Tensor, torch::Tensor>
2121
ego_k_hop_sample_adj(torch::Tensor rowptr, torch::Tensor col, torch::Tensor idx,
2222
int64_t depth, int64_t num_neighbors, bool replace) {

csrc/extensions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#include <torch/torch.h>
3+
#include "sparse.h"
34

45
// for getpid()
56
#ifdef _WIN32

csrc/hgt_sample.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ PyMODINIT_FUNC PyInit__hgt_sample_cpu(void) { return NULL; }
1616
#endif
1717

1818
// Returns 'output_node_dict', 'row_dict', 'col_dict', 'output_edge_dict'
19-
std::tuple<c10::Dict<node_t, torch::Tensor>, c10::Dict<rel_t, torch::Tensor>,
19+
SPARSE_API std::tuple<c10::Dict<node_t, torch::Tensor>, c10::Dict<rel_t, torch::Tensor>,
2020
c10::Dict<rel_t, torch::Tensor>, c10::Dict<rel_t, torch::Tensor>>
2121
hgt_sample(const c10::Dict<std::string, torch::Tensor> &colptr_dict,
2222
const c10::Dict<std::string, torch::Tensor> &row_dict,

csrc/metis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PyMODINIT_FUNC PyInit__metis_cpu(void) { return NULL; }
1515
#endif
1616
#endif
1717

18-
torch::Tensor partition(torch::Tensor rowptr, torch::Tensor col,
18+
SPARSE_API torch::Tensor partition(torch::Tensor rowptr, torch::Tensor col,
1919
torch::optional<torch::Tensor> optional_value,
2020
int64_t num_parts, bool recursive) {
2121
if (rowptr.device().is_cuda()) {
@@ -30,7 +30,7 @@ torch::Tensor partition(torch::Tensor rowptr, torch::Tensor col,
3030
}
3131
}
3232

33-
torch::Tensor partition2(torch::Tensor rowptr, torch::Tensor col,
33+
SPARSE_API torch::Tensor partition2(torch::Tensor rowptr, torch::Tensor col,
3434
torch::optional<torch::Tensor> optional_value,
3535
torch::optional<torch::Tensor> optional_node_weight,
3636
int64_t num_parts, bool recursive) {
@@ -46,7 +46,7 @@ torch::Tensor partition2(torch::Tensor rowptr, torch::Tensor col,
4646
}
4747
}
4848

49-
torch::Tensor mt_partition(torch::Tensor rowptr, torch::Tensor col,
49+
SPARSE_API torch::Tensor mt_partition(torch::Tensor rowptr, torch::Tensor col,
5050
torch::optional<torch::Tensor> optional_value,
5151
torch::optional<torch::Tensor> optional_node_weight,
5252
int64_t num_parts, bool recursive,

csrc/neighbor_sample.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ PyMODINIT_FUNC PyInit__neighbor_sample_cpu(void) { return NULL; }
1616
#endif
1717

1818
// Returns 'output_node', 'row', 'col', 'output_edge'
19-
std::tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor>
19+
SPARSE_API std::tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor>
2020
neighbor_sample(const torch::Tensor &colptr, const torch::Tensor &row,
2121
const torch::Tensor &input_node,
2222
const std::vector<int64_t> num_neighbors, const bool replace,
@@ -25,7 +25,7 @@ neighbor_sample(const torch::Tensor &colptr, const torch::Tensor &row,
2525
directed);
2626
}
2727

28-
std::tuple<c10::Dict<node_t, torch::Tensor>, c10::Dict<rel_t, torch::Tensor>,
28+
SPARSE_API std::tuple<c10::Dict<node_t, torch::Tensor>, c10::Dict<rel_t, torch::Tensor>,
2929
c10::Dict<rel_t, torch::Tensor>, c10::Dict<rel_t, torch::Tensor>>
3030
hetero_neighbor_sample(
3131
const std::vector<node_t> &node_types,

csrc/relabel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PyMODINIT_FUNC PyInit__relabel_cpu(void) { return NULL; }
1515
#endif
1616
#endif
1717

18-
std::tuple<torch::Tensor, torch::Tensor> relabel(torch::Tensor col,
18+
SPARSE_API std::tuple<torch::Tensor, torch::Tensor> relabel(torch::Tensor col,
1919
torch::Tensor idx) {
2020
if (col.device().is_cuda()) {
2121
#ifdef WITH_CUDA
@@ -28,7 +28,7 @@ std::tuple<torch::Tensor, torch::Tensor> relabel(torch::Tensor col,
2828
}
2929
}
3030

31-
std::tuple<torch::Tensor, torch::Tensor, torch::optional<torch::Tensor>,
31+
SPARSE_API std::tuple<torch::Tensor, torch::Tensor, torch::optional<torch::Tensor>,
3232
torch::Tensor>
3333
relabel_one_hop(torch::Tensor rowptr, torch::Tensor col,
3434
torch::optional<torch::Tensor> optional_value,

csrc/rw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ PyMODINIT_FUNC PyInit__rw_cpu(void) { return NULL; }
1919
#endif
2020
#endif
2121

22-
torch::Tensor random_walk(torch::Tensor rowptr, torch::Tensor col,
22+
SPARSE_API torch::Tensor random_walk(torch::Tensor rowptr, torch::Tensor col,
2323
torch::Tensor start, int64_t walk_length) {
2424
if (rowptr.device().is_cuda()) {
2525
#ifdef WITH_CUDA

csrc/sample.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PyMODINIT_FUNC PyInit__sample_cpu(void) { return NULL; }
1515
#endif
1616
#endif
1717

18-
std::tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor>
18+
SPARSE_API std::tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor>
1919
sample_adj(torch::Tensor rowptr, torch::Tensor col, torch::Tensor idx,
2020
int64_t num_neighbors, bool replace) {
2121
if (rowptr.device().is_cuda()) {

0 commit comments

Comments
 (0)