Skip to content

Fix: float32 bug in UTs #3314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions deepmd/pt/model/network/mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ def forward(
yy: torch.Tensor
The output.
"""
ori_prec = xx.dtype
xx = xx.to(self.prec)
yy = (
torch.matmul(xx, self.matrix) + self.bias
if self.bias is not None
Expand All @@ -128,6 +130,7 @@ def forward(
yy += torch.concat([xx, xx], dim=-1)
else:
yy = yy
yy = yy.to(ori_prec)
return yy

def serialize(self) -> dict:
Expand Down
3 changes: 1 addition & 2 deletions source/tests/consistent/fitting/test_ener.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ def skip_pt(self) -> bool:
mixed_types,
numb_fparam,
) = self.param
# TODO: float32 has bug
return precision == "float32" or CommonTest.skip_pt
return CommonTest.skip_pt

tf_class = EnerFittingTF
dp_class = EnerFittingDP
Expand Down