version.cpp 724 Bytes
Newer Older
quyuanhao123's avatar
quyuanhao123 committed
1
2
3
4
5
#ifdef WITH_PYTHON
#include <Python.h>
#endif
#include <torch/script.h>

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

aiss's avatar
aiss committed
14
15
#include "macros.h"

quyuanhao123's avatar
quyuanhao123 committed
16
17
#ifdef _WIN32
#ifdef WITH_PYTHON
aiss's avatar
aiss committed
18
#ifdef WITH_CUDA
quyuanhao123's avatar
quyuanhao123 committed
19
20
21
22
23
24
25
PyMODINIT_FUNC PyInit__version_cuda(void) { return NULL; }
#else
PyMODINIT_FUNC PyInit__version_cpu(void) { return NULL; }
#endif
#endif
#endif

aiss's avatar
aiss committed
26
27
28
29
30
31
32
33
namespace sparse {
SPARSE_API int64_t cuda_version() noexcept {
#ifdef WITH_CUDA
#ifdef USE_ROCM
  return HIP_VERSION;
#else
  return CUDA_VERSION;
#endif
quyuanhao123's avatar
quyuanhao123 committed
34
35
36
37
#else
  return -1;
#endif
}
aiss's avatar
aiss committed
38
} // namespace sparse
quyuanhao123's avatar
quyuanhao123 committed
39

aiss's avatar
aiss committed
40
41
static auto registry = torch::RegisterOperators().op(
    "torch_sparse::cuda_version", [] { return sparse::cuda_version(); });