DynamicLibrary.h 679 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include <ATen/Utils.h>
  3. #include <c10/macros/Export.h>
  4. #include <c10/util/Exception.h>
  5. namespace c10 {
  6. class DynamicLibraryError : public Error {
  7. using Error::Error;
  8. };
  9. } // namespace c10
  10. namespace at {
  11. struct DynamicLibrary {
  12. AT_DISALLOW_COPY_AND_ASSIGN(DynamicLibrary);
  13. DynamicLibrary(DynamicLibrary&& other) = delete;
  14. DynamicLibrary& operator=(DynamicLibrary&&) = delete;
  15. TORCH_API DynamicLibrary(
  16. const char* name,
  17. const char* alt_name = nullptr,
  18. bool leak_handle = false);
  19. TORCH_API void* sym(const char* name);
  20. TORCH_API ~DynamicLibrary();
  21. private:
  22. bool leak_handle;
  23. void* handle = nullptr;
  24. };
  25. } // namespace at