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

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

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

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

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

34
35
TORCH_LIBRARY_FRAGMENT(torchvision, m) {
  m.def("_cuda_version", &cuda_version);
36
}
37
} // namespace vision