dmlc--dgl
3b0c0cec46
* enable sparse on windows and mac * that was stupid * let's see what's going on.. * [Sparse] Fix the import error on Mac OS. When using template functions that are defined in source files from DGL, the loader of MacOS somehow cannot find their definitions. This fix simply avoids depending on template functions from DGL headers. With this fix, the sparse tests all pass on the MAC environment. * ok this is the problem * make errors clearer * uh * test * Update __init__.py * disabling ddp on windows --------- Co-authored-by: czkkkkkk <zekucai@gmail.com>
46 行
1.3 KiB
Python
46 行
1.3 KiB
Python
"""dgl sparse class."""
|
|
import os
|
|
import sys
|
|
|
|
import torch
|
|
|
|
from .._ffi import libinfo
|
|
from .diag_matrix import *
|
|
from .elementwise_op import *
|
|
from .elementwise_op_diag import *
|
|
from .elementwise_op_sp import *
|
|
from .matmul import *
|
|
from .reduction import * # pylint: disable=W0622
|
|
from .sddmm import *
|
|
from .softmax import *
|
|
from .sparse_matrix import *
|
|
from .unary_op_diag import *
|
|
from .unary_op_sp import *
|
|
|
|
|
|
def load_dgl_sparse():
|
|
"""Load DGL C++ sparse library"""
|
|
version = torch.__version__.split("+", maxsplit=1)[0]
|
|
|
|
if sys.platform.startswith("linux"):
|
|
basename = f"libdgl_sparse_pytorch_{version}.so"
|
|
elif sys.platform.startswith("darwin"):
|
|
basename = f"libdgl_sparse_pytorch_{version}.dylib"
|
|
elif sys.platform.startswith("win"):
|
|
basename = f"dgl_sparse_pytorch_{version}.dll"
|
|
else:
|
|
raise NotImplementedError("Unsupported system: %s" % sys.platform)
|
|
|
|
dirname = os.path.dirname(libinfo.find_lib_path()[0])
|
|
path = os.path.join(dirname, "dgl_sparse", basename)
|
|
if not os.path.exists(path):
|
|
raise FileNotFoundError(f"Cannot find DGL C++ sparse library at {path}")
|
|
|
|
try:
|
|
torch.classes.load_library(path)
|
|
except Exception: # pylint: disable=W0703
|
|
raise ImportError("Cannot load DGL C++ sparse library")
|
|
|
|
|
|
load_dgl_sparse()
|