Skip to content

Commit 16bff4b

Browse files
committed
fix jit
1 parent 9b68fe2 commit 16bff4b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

deepmd/pt/model/network/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def aggregate(
1818
owners: torch.Tensor,
1919
average: bool = True,
2020
num_owner: Optional[int] = None,
21+
use_torch_scatter: bool = has_torch_scatter,
2122
) -> torch.Tensor:
2223
"""
2324
Aggregate rows in data by specifying the owners.
@@ -31,13 +32,17 @@ def aggregate(
3132
num_owner : the number of owners, this is needed if the
3233
max idx of owner is not presented in owners tensor
3334
Default = None
35+
use_torch_scatter : if True, use torch_scatter to aggregate,
36+
which is faster and more memory efficient.
37+
if False, use native index_add_.
38+
Default = True if torch_scatter is available, else False
3439
3540
Returns
3641
-------
3742
output: [num_owner, feature_dim]
3843
"""
3944
# faster and recommended
40-
if has_torch_scatter:
45+
if use_torch_scatter:
4146
output = torch_scatter.segment_coo(
4247
src=data,
4348
index=owners,

0 commit comments

Comments
 (0)