1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#ifdef WITH_PYTHON
#include <Python.h>
#endif
#include <torch/script.h>
#include "cpu/metis_cpu.h"
#ifdef _WIN32
#ifdef WITH_PYTHON
#ifdef WITH_CUDA
PyMODINIT_FUNC PyInit__metis_cuda(void) { return NULL; }
#else
PyMODINIT_FUNC PyInit__metis_cpu(void) { return NULL; }
#endif
#endif
#endif
SPARSE_API torch::Tensor partition(torch::Tensor rowptr, torch::Tensor col,
std::optional<torch::Tensor> optional_value,
int64_t num_parts, bool recursive) {
if (rowptr.device().is_cuda()) {
#ifdef WITH_CUDA
AT_ERROR("No CUDA version supported");
#else
AT_ERROR("Not compiled with CUDA support");
#endif
} else {
return partition_cpu(rowptr, col, optional_value, std::nullopt, num_parts,
recursive);
}
}
SPARSE_API torch::Tensor partition2(torch::Tensor rowptr, torch::Tensor col,
std::optional<torch::Tensor> optional_value,
std::optional<torch::Tensor> optional_node_weight,
int64_t num_parts, bool recursive) {
if (rowptr.device().is_cuda()) {
#ifdef WITH_CUDA
AT_ERROR("No CUDA version supported");
#else
AT_ERROR("Not compiled with CUDA support");
#endif
} else {
return partition_cpu(rowptr, col, optional_value, optional_node_weight,
num_parts, recursive);
}
}
SPARSE_API torch::Tensor mt_partition(torch::Tensor rowptr, torch::Tensor col,
std::optional<torch::Tensor> optional_value,
std::optional<torch::Tensor> optional_node_weight,
int64_t num_parts, bool recursive,
int64_t num_workers) {
if (rowptr.device().is_cuda()) {
#ifdef WITH_CUDA
AT_ERROR("No CUDA version supported");
#else
AT_ERROR("Not compiled with CUDA support");
#endif
} else {
return mt_partition_cpu(rowptr, col, optional_value, optional_node_weight,
num_parts, recursive, num_workers);
}
}
static auto registry = torch::RegisterOperators()
.op("torch_sparse::partition", &partition)
.op("torch_sparse::partition2", &partition2)
.op("torch_sparse::mt_partition", &mt_partition);
|