Skip to content

Commit 1a07636

Browse files
update missing file
1 parent d6a3b1e commit 1a07636

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

deepmd/pd/cxx_op.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
]

0 commit comments

Comments
 (0)