File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: LGPL-3.0-or-later
2+ from pathlib import (
3+ Path ,
4+ )
5+ from types import (
6+ ModuleType ,
7+ )
8+
9+ from paddle .utils .cpp_extension import (
10+ load ,
11+ )
12+
13+
14+ def load_library (module_name : str ) -> tuple [bool , ModuleType ]:
15+ """Load OP library and return the module if success.
16+
17+ Parameters
18+ ----------
19+ module_name : str
20+ Name of the module
21+
22+ Returns
23+ -------
24+ bool
25+ Whether the library is loaded successfully
26+ ModuleType
27+ loaded custom operator module
28+ """
29+ current_file = Path (__file__ ).resolve ()
30+ base_dir = current_file .parents [2 ]
31+
32+ module_file = base_dir / "source" / "op" / "pd" / "comm.cc"
33+ paddle_ops_deepmd = load (
34+ name = "deepmd_op_pd" ,
35+ sources = [str (module_file )],
36+ )
37+ return True , paddle_ops_deepmd
38+
39+
40+ ENABLE_CUSTOMIZED_OP , paddle_ops_deepmd = load_library ("deepmd_op_pd" )
41+
42+ __all__ = [
43+ "ENABLE_CUSTOMIZED_OP" ,
44+ "paddle_ops_deepmd" ,
45+ ]
You can’t perform that action at this time.
0 commit comments