"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "504ff7bb1234991eb07595c123b264a8a1064bd3"
Unverified Commit b5b3445c authored by Sam Shleifer's avatar Sam Shleifer Committed by GitHub
Browse files

Only use F.gelu for torch >=1.4.0 (#2955)

* Only use F.gelu for torch >=1.4.0

* Use F.gelu for newer torch
parent fc38d4c8
...@@ -18,7 +18,10 @@ def _gelu_python(x): ...@@ -18,7 +18,10 @@ def _gelu_python(x):
return x * 0.5 * (1.0 + torch.erf(x / math.sqrt(2.0))) return x * 0.5 * (1.0 + torch.erf(x / math.sqrt(2.0)))
gelu = getattr(F, "gelu", _gelu_python) if torch.__version__ < "1.4.0":
gelu = _gelu_python
else:
gelu = F.gelu
def gelu_new(x): def gelu_new(x):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment