Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions deepmd/pt/model/network/layernorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@
# variance = xx.var(dim=-1, unbiased=False, keepdim=True)
# The following operation is the same as above, but will not raise error when using jit model to inference.
# See https://github.com/pytorch/pytorch/issues/85792
variance, mean = torch.var_mean(xx, dim=-1, unbiased=False, keepdim=True)
yy = (xx - mean) / torch.sqrt(variance + self.eps)
if xx.numel() > 0:
variance, mean = torch.var_mean(xx, dim=-1, unbiased=False, keepdim=True)
yy = (xx - mean) / torch.sqrt(variance + self.eps)

Check warning on line 101 in deepmd/pt/model/network/layernorm.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/network/layernorm.py#L99-L101

Added lines #L99 - L101 were not covered by tests
else:
yy = xx

Check warning on line 103 in deepmd/pt/model/network/layernorm.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/network/layernorm.py#L103

Added line #L103 was not covered by tests
if self.matrix is not None and self.bias is not None:
yy = yy * self.matrix + self.bias
return yy
Expand Down