Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
b5b3445c
Unverified
Commit
b5b3445c
authored
Feb 21, 2020
by
Sam Shleifer
Committed by
GitHub
Feb 21, 2020
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
src/transformers/activations.py
src/transformers/activations.py
+4
-1
No files found.
src/transformers/activations.py
View file @
b5b3445c
...
...
@@ -18,7 +18,10 @@ def _gelu_python(x):
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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment