"vscode:/vscode.git/clone" did not exist on "08c852290a060b8ac21f263f897e1c9e25e1eda3"
nearest.cpp 738 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
#include <Python.h>
#include <torch/script.h>

YoannPitarch's avatar
YoannPitarch committed
4
5
#include "extensions.h"

rusty1s's avatar
rusty1s committed
6
7
8
9
10
#ifdef WITH_CUDA
#include "cuda/nearest_cuda.h"
#endif

#ifdef _WIN32
rusty1s's avatar
rusty1s committed
11
12
13
14
15
#ifdef WITH_CUDA
PyMODINIT_FUNC PyInit__nearest_cuda(void) { return NULL; }
#else
PyMODINIT_FUNC PyInit__nearest_cpu(void) { return NULL; }
#endif
rusty1s's avatar
rusty1s committed
16
17
#endif

YoannPitarch's avatar
YoannPitarch committed
18
CLUSTER_API torch::Tensor nearest(torch::Tensor x, torch::Tensor y, torch::Tensor ptr_x,
rusty1s's avatar
rusty1s committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
                      torch::Tensor ptr_y) {
  if (x.device().is_cuda()) {
#ifdef WITH_CUDA
    return nearest_cuda(x, y, ptr_x, ptr_y);
#else
    AT_ERROR("Not compiled with CUDA support");
#endif
  } else {
    AT_ERROR("No CPU version supported");
  }
}

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