Skip to content

Commit f9196c5

Browse files
committed
feat(paddle): Enable ANN rule for loss directory base files
- Enable ANN rule for loss/__init__.py and loss/loss.py - Add proper type annotations to TaskLoss class methods - Update abstract method signatures with proper types - Progress: 9 files now fully completed with ANN rule enabled
1 parent 8bbdd1f commit f9196c5

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

deepmd/pd/loss/loss.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
ABC,
44
abstractmethod,
55
)
6+
from typing import (
7+
NoReturn,
8+
)
69

710
import paddle
811

@@ -15,11 +18,11 @@
1518

1619

1720
class TaskLoss(paddle.nn.Layer, ABC, make_plugin_registry("loss")):
18-
def __init__(self, **kwargs):
21+
def __init__(self) -> None:
1922
"""Construct loss."""
2023
super().__init__()
2124

22-
def forward(self, input_dict, model, label, natoms, learning_rate):
25+
def forward(self, input_dict: dict[str, paddle.Tensor], model: paddle.nn.Layer, label: dict[str, paddle.Tensor], natoms: int, learning_rate: float) -> NoReturn:
2326
"""Return loss ."""
2427
raise NotImplementedError
2528

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,12 @@ runtime-evaluated-base-classes = ["torch.nn.Module"]
436436
"deepmd/pd/utils/update_sel.py" = ["TID253"] # ✅ Fully typed
437437
"deepmd/pd/utils/preprocess.py" = ["TID253"] # ✅ Fully typed
438438
"deepmd/pd/utils/spin.py" = ["TID253"] # ✅ Fully typed
439+
"deepmd/pd/loss/__init__.py" = ["TID253"] # ✅ Fully typed
440+
"deepmd/pd/loss/loss.py" = ["TID253"] # ✅ Fully typed
439441
# TODO: Complete type hints and remove ANN exclusion for remaining files:
440442
"deepmd/pd/train/**" = ["TID253", "ANN"] # 🚧 Partial progress - training.py still needs work
441443
"deepmd/pd/utils/**" = ["TID253", "ANN"] # 🚧 Partial progress - utils.py partially done
442-
"deepmd/pd/loss/**" = ["TID253", "ANN"] # ❌ Not started
444+
"deepmd/pd/loss/**" = ["TID253", "ANN"] # 🚧 Partial progress - ener.py still needs work
443445
"deepmd/pd/model/**" = ["TID253", "ANN"] # ❌ Not started
444446
"deepmd/pd/infer/**" = ["TID253", "ANN"] # ❌ Not started
445447
"deepmd/pd/cxx_op.py" = ["ANN"] # ❌ Not started

0 commit comments

Comments
 (0)