Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

_internally_replaced_utils.py 1.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  1. import importlib.machinery
  2. import os
  3. from torch.hub import _get_torch_home
  4. _HOME = os.path.join(_get_torch_home(), "datasets", "vision")
  5. _USE_SHARDED_DATASETS = False
  6. IN_FBCODE = False
  7. def _download_file_from_remote_location(fpath: str, url: str) -> None:
  8. pass
  9. def _is_remote_location_available() -> bool:
  10. return False
  11. try:
  12. from torch.hub import load_state_dict_from_url # noqa: 401
  13. except ImportError:
  14. from torch.utils.model_zoo import load_url as load_state_dict_from_url # noqa: 401
  15. def _get_extension_path(lib_name):
  16. lib_dir = os.path.dirname(__file__)
  17. if os.name == "nt":
  18. # Register the main torchvision library location on the default DLL path
  19. import ctypes
  20. kernel32 = ctypes.WinDLL("kernel32.dll", use_last_error=True)
  21. with_load_library_flags = hasattr(kernel32, "AddDllDirectory")
  22. prev_error_mode = kernel32.SetErrorMode(0x0001)
  23. if with_load_library_flags:
  24. kernel32.AddDllDirectory.restype = ctypes.c_void_p
  25. os.add_dll_directory(lib_dir)
  26. kernel32.SetErrorMode(prev_error_mode)
  27. loader_details = (importlib.machinery.ExtensionFileLoader, importlib.machinery.EXTENSION_SUFFIXES)
  28. extfinder = importlib.machinery.FileFinder(lib_dir, loader_details)
  29. ext_specs = extfinder.find_spec(lib_name)
  30. if ext_specs is None:
  31. raise ImportError
  32. return ext_specs.origin
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...