rw.cpp 669 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
4
5
6
#include <Python.h>
#include <torch/script.h>

#include "cpu/rw_cpu.h"

#ifdef _WIN32
rusty1s's avatar
rusty1s committed
7
PyMODINIT_FUNC PyInit__rw(void) { return NULL; }
rusty1s's avatar
rusty1s committed
8
9
#endif

rusty1s's avatar
rusty1s committed
10
11
12
13
torch::Tensor random_walk(torch::Tensor rowptr, torch::Tensor col,
                          torch::Tensor start, int64_t walk_length, double p,
                          double q) {
  if (rowptr.device().is_cuda()) {
rusty1s's avatar
rusty1s committed
14
#ifdef WITH_CUDA
rusty1s's avatar
rusty1s committed
15
    AT_ERROR("No CUDA version supported");
rusty1s's avatar
rusty1s committed
16
17
18
19
#else
    AT_ERROR("Not compiled with CUDA support");
#endif
  } else {
rusty1s's avatar
rusty1s committed
20
    return random_walk_cpu(rowptr, col, start, walk_length, p, q);
rusty1s's avatar
rusty1s committed
21
22
23
24
  }
}

static auto registry =
rusty1s's avatar
rusty1s committed
25
    torch::RegisterOperators().op("torch_cluster::random_walk", &random_walk);