version.cpp 587 Bytes
Newer Older
quyuanhao123's avatar
quyuanhao123 committed
1
2
3
#include <Python.h>
#include <torch/script.h>

limm's avatar
limm committed
4
#ifdef WITH_CUDA
limm's avatar
limm committed
5
6
7
#ifdef USE_ROCM
#include <hip/hip_version.h>
#else
limm's avatar
limm committed
8
#include <cuda.h>
quyuanhao123's avatar
quyuanhao123 committed
9
#endif
limm's avatar
limm committed
10
#endif
quyuanhao123's avatar
quyuanhao123 committed
11
12

#ifdef _WIN32
limm's avatar
limm committed
13
#ifdef WITH_CUDA
quyuanhao123's avatar
quyuanhao123 committed
14
15
16
17
18
19
20
PyMODINIT_FUNC PyInit__version_cuda(void) { return NULL; }
#else
PyMODINIT_FUNC PyInit__version_cpu(void) { return NULL; }
#endif
#endif

int64_t cuda_version() {
limm's avatar
limm committed
21
#ifdef WITH_CUDA
limm's avatar
limm committed
22
23
24
#ifdef USE_ROCM
  return HIP_VERSION;
#else
limm's avatar
limm committed
25
  return CUDA_VERSION;
limm's avatar
limm committed
26
#endif
quyuanhao123's avatar
quyuanhao123 committed
27
28
29
30
31
32
#else
  return -1;
#endif
}

static auto registry = torch::RegisterOperators().op(
limm's avatar
limm committed
33
    "torch_spline_conv::cuda_version", [] { return cuda_version(); });