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

3
#ifndef MOBILE
4
#ifdef USE_PYTHON
5
#include <Python.h>
6
#endif
7
#endif
8
#include <torch/library.h>
9
10
11
12

#ifdef WITH_CUDA
#include <cuda.h>
#endif
13
14
15
#ifdef WITH_HIP
#include <hip/hip_runtime.h>
#endif
16
17

// If we are in a Windows environment, we need to define
18
19
20
// initialization functions for the _custom_ops extension.
// For PyMODINIT_FUNC to work, we need to include Python.h
#if !defined(MOBILE) && defined(_WIN32)
21
#ifdef USE_PYTHON
22
PyMODINIT_FUNC PyInit__C(void) {
23
24
25
  // No need to do anything.
  return NULL;
}
26
#endif // USE_PYTHON
27
#endif // !defined(MOBILE) && defined(_WIN32)
28

29
namespace vision {
30
int64_t cuda_version() {
31
#ifdef WITH_CUDA
32
33
34
  return CUDA_VERSION;
#else
  return -1;
35
#endif
36
}
37

38
39
TORCH_LIBRARY_FRAGMENT(torchvision, m) {
  m.def("_cuda_version", &cuda_version);
40
}
41
} // namespace vision