DynamicLibrary.h 933 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
  2. #pragma once
  3. #include <ATen/Utils.h>
  4. #include <c10/macros/Export.h>
  5. #include <c10/util/Exception.h>
  6. namespace c10 {
  7. class DynamicLibraryError : public Error {
  8. using Error::Error;
  9. };
  10. } // namespace c10
  11. namespace at {
  12. struct DynamicLibrary {
  13. AT_DISALLOW_COPY_AND_ASSIGN(DynamicLibrary);
  14. DynamicLibrary(DynamicLibrary&& other) = delete;
  15. DynamicLibrary& operator=(DynamicLibrary&&) = delete;
  16. TORCH_API DynamicLibrary(
  17. const char* name,
  18. const char* alt_name = nullptr,
  19. bool leak_handle = false);
  20. TORCH_API void* sym(const char* name);
  21. TORCH_API ~DynamicLibrary();
  22. private:
  23. bool leak_handle;
  24. void* handle = nullptr;
  25. };
  26. } // namespace at
  27. #else
  28. #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
  29. #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)