fps.cpp 783 Bytes
Newer Older
1
#ifdef WITH_PYTHON
rusty1s's avatar
rusty1s committed
2
#include <Python.h>
3
#endif
rusty1s's avatar
rusty1s committed
4
5
6
7
8
9
10
11
12
#include <torch/script.h>

#include "cpu/fps_cpu.h"

#ifdef WITH_CUDA
#include "cuda/fps_cuda.h"
#endif

#ifdef _WIN32
13
#ifdef WITH_PYTHON
rusty1s's avatar
rusty1s committed
14
15
16
17
18
#ifdef WITH_CUDA
PyMODINIT_FUNC PyInit__fps_cuda(void) { return NULL; }
#else
PyMODINIT_FUNC PyInit__fps_cpu(void) { return NULL; }
#endif
rusty1s's avatar
rusty1s committed
19
#endif
20
#endif
rusty1s's avatar
rusty1s committed
21

YoannPitarch's avatar
YoannPitarch committed
22
CLUSTER_API torch::Tensor fps(torch::Tensor src, torch::Tensor ptr, torch::Tensor ratio,
rusty1s's avatar
rusty1s committed
23
24
25
                  bool random_start) {
  if (src.device().is_cuda()) {
#ifdef WITH_CUDA
rusty1s's avatar
rusty1s committed
26
    return fps_cuda(src, ptr, ratio, random_start);
rusty1s's avatar
rusty1s committed
27
28
29
30
#else
    AT_ERROR("Not compiled with CUDA support");
#endif
  } else {
rusty1s's avatar
rusty1s committed
31
    return fps_cpu(src, ptr, ratio, random_start);
rusty1s's avatar
rusty1s committed
32
33
34
35
36
  }
}

static auto registry =
    torch::RegisterOperators().op("torch_cluster::fps", &fps);