vision.cpp 599 Bytes
Newer Older
1
2
#include "vision.h"

3
#include <Python.h>
4
#include <torch/library.h>
5
6
7
8

#ifdef WITH_CUDA
#include <cuda.h>
#endif
9
10
11
#ifdef WITH_HIP
#include <hip/hip_runtime.h>
#endif
12
13

// If we are in a Windows environment, we need to define
14
// initialization functions for the _custom_ops extension
15
#ifdef _WIN32
16
PyMODINIT_FUNC PyInit__C(void) {
17
18
19
20
  // No need to do anything.
  return NULL;
}
#endif
21

22
namespace vision {
23
int64_t cuda_version() {
24
#ifdef WITH_CUDA
25
26
27
  return CUDA_VERSION;
#else
  return -1;
28
#endif
29
}
30

31
32
TORCH_LIBRARY_FRAGMENT(torchvision, m) {
  m.def("_cuda_version", &cuda_version);
33
}
34
} // namespace vision