vision.cpp 810 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "vision.h"
  2. #ifndef MOBILE
  3. #ifdef USE_PYTHON
  4. #include <Python.h>
  5. #endif
  6. #endif
  7. #include <torch/library.h>
  8. #ifdef WITH_CUDA
  9. #include <cuda.h>
  10. #endif
  11. #ifdef WITH_HIP
  12. #include <hip/hip_runtime.h>
  13. #endif
  14. // If we are in a Windows environment, we need to define
  15. // initialization functions for the _custom_ops extension.
  16. // For PyMODINIT_FUNC to work, we need to include Python.h
  17. #if !defined(MOBILE) && defined(_WIN32)
  18. #ifdef USE_PYTHON
  19. PyMODINIT_FUNC PyInit__C(void) {
  20. // No need to do anything.
  21. return NULL;
  22. }
  23. #endif // USE_PYTHON
  24. #endif // !defined(MOBILE) && defined(_WIN32)
  25. namespace vision {
  26. int64_t cuda_version() {
  27. #ifdef WITH_CUDA
  28. return CUDA_VERSION;
  29. #else
  30. return -1;
  31. #endif
  32. }
  33. TORCH_LIBRARY_FRAGMENT(torchvision, m) {
  34. m.def("_cuda_version", &cuda_version);
  35. }
  36. } // namespace vision