sample.cpp 685 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
4
5
6
7
8
9
10
#include <Python.h>
#include <torch/script.h>

#include "cpu/sample_cpu.h"

#ifdef _WIN32
PyMODINIT_FUNC PyInit__sample(void) { return NULL; }
#endif

std::tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor>
11
12
sample_adj(torch::Tensor rowptr, torch::Tensor col, torch::Tensor idx,
           int64_t num_neighbors, bool replace) {
rusty1s's avatar
rusty1s committed
13
14
15
16
17
18
19
  if (rowptr.device().is_cuda()) {
#ifdef WITH_CUDA
    AT_ERROR("No CUDA version supported");
#else
    AT_ERROR("Not compiled with CUDA support");
#endif
  } else {
20
    return sample_adj_cpu(rowptr, col, idx, num_neighbors, replace);
rusty1s's avatar
rusty1s committed
21
22
23
24
25
  }
}

static auto registry =
    torch::RegisterOperators().op("torch_sparse::sample_adj", &sample_adj);