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
d4867951
Unverified
Commit
d4867951
authored
Apr 16, 2020
by
Lysandre Debut
Committed by
GitHub
Apr 16, 2020
Browse files
JIT not compatible with PyTorch/XLA (#3743)
parent
b1e2368b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
src/transformers/activations.py
src/transformers/activations.py
+13
-1
No files found.
src/transformers/activations.py
View file @
d4867951
import
logging
import
math
import
torch
import
torch.nn.functional
as
F
logger
=
logging
.
getLogger
(
__name__
)
def
swish
(
x
):
return
x
*
torch
.
sigmoid
(
x
)
...
...
@@ -29,7 +33,15 @@ if torch.__version__ < "1.4.0":
gelu
=
_gelu_python
else
:
gelu
=
F
.
gelu
gelu_new
=
torch
.
jit
.
script
(
gelu_new
)
try
:
import
torch_xla
# noqa F401
logger
.
warning
(
"The torch_xla package was detected in the python environment. PyTorch/XLA and JIT is untested,"
" no activation function will be traced with JIT."
)
except
ImportError
:
gelu_new
=
torch
.
jit
.
script
(
gelu_new
)
ACT2FN
=
{
"relu"
:
F
.
relu
,
...
...
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