-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy path__init__.py
55 lines (38 loc) · 1.22 KB
/
__init__.py
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
52
53
54
55
import importlib
import os
import os.path as osp
import warnings
import torch
from pyg_lib.home import get_home_dir, set_home_dir
__version__ = '0.4.0'
# * `libpyg.so`: The name of the shared library file.
# * `torch.ops.pyg`: The used namespace.
# * `pyg_lib`: The name of the Python package.
def load_library(lib_name: str) -> None:
if bool(os.getenv('BUILD_DOCS', 0)):
return
loader_details = (importlib.machinery.ExtensionFileLoader,
importlib.machinery.EXTENSION_SUFFIXES)
path = osp.abspath(osp.join(osp.dirname(__file__), '..'))
ext_finder = importlib.machinery.FileFinder(path, loader_details)
spec = ext_finder.find_spec(lib_name)
if spec is None:
warnings.warn(f"Could not find shared library '{lib_name}'")
else:
torch.ops.load_library(spec.origin)
load_library('libpyg')
import pyg_lib.ops # noqa
import pyg_lib.partition # noqa
import pyg_lib.sampler # noqa
def cuda_version() -> int:
r"""Returns the CUDA version for which :obj:`pyg_lib` was compiled with.
Returns:
The CUDA version.
"""
return torch.ops.pyg.cuda_version()
__all__ = [
'__version__',
'cuda_version',
'get_home_dir',
'set_home_dir',
]