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

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

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

quyuanhao123's avatar
quyuanhao123 committed
16
17
#ifdef _WIN32
#ifdef WITH_PYTHON
limm's avatar
limm 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

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

limm's avatar
limm committed
40
41
42
43
// static auto registry = torch::RegisterOperators().op(
//    "torch_sparse::cuda_version", &sparse::cuda_version);

static auto registry = torch::RegisterOperators().op("torch_sparse::cuda_version", [] { return sparse::cuda_version(); }); // support torch>=2.1.0