Skip to content

Commit

Permalink
pt: make gelu jit happy
Browse files Browse the repository at this point in the history
  • Loading branch information
iProzd committed Mar 28, 2024
1 parent 6da8eef commit 7818956
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion deepmd/pt/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ def get_activation_fn(activation: str) -> Callable:
if activation.lower() == "relu":
return F.relu
elif activation.lower() == "gelu" or activation.lower() == "gelu_tf":
return lambda x: F.gelu(x, approximate="tanh")

@torch.jit.script
def gelu_tanh(x):
return F.gelu(x, approximate="tanh")

Check warning on line 29 in deepmd/pt/utils/utils.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/utils/utils.py#L27-L29

Added lines #L27 - L29 were not covered by tests

return gelu_tanh

Check warning on line 31 in deepmd/pt/utils/utils.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/utils/utils.py#L31

Added line #L31 was not covered by tests
elif activation.lower() == "tanh":
return torch.tanh
elif activation.lower() == "relu6":
Expand Down

0 comments on commit 7818956

Please sign in to comment.