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

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

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

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

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