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
faef6f61
Commit
faef6f61
authored
Dec 19, 2019
by
Morgan Funtowicz
Browse files
Fix logic order for USE_TF/USE_TORCH
parent
5664327c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
transformers/file_utils.py
transformers/file_utils.py
+8
-6
No files found.
transformers/file_utils.py
View file @
faef6f61
...
@@ -29,25 +29,27 @@ logger = logging.getLogger(__name__) # pylint: disable=invalid-name
...
@@ -29,25 +29,27 @@ logger = logging.getLogger(__name__) # pylint: disable=invalid-name
try
:
try
:
os
.
environ
.
setdefault
(
'USE_TF'
,
'YES'
)
os
.
environ
.
setdefault
(
'USE_TF'
,
'YES'
)
if
os
.
environ
[
'USE_TF'
].
upper
()
in
(
'1'
,
'ON'
,
'YES'
):
if
os
.
environ
[
'USE_TF'
].
upper
()
in
(
'1'
,
'ON'
,
'YES'
):
logger
.
info
(
"USE_TF override through env variable, disabling Tensorflow"
)
_tf_available
=
False
else
:
import
tensorflow
as
tf
import
tensorflow
as
tf
assert
hasattr
(
tf
,
'__version__'
)
and
int
(
tf
.
__version__
[
0
])
>=
2
assert
hasattr
(
tf
,
'__version__'
)
and
int
(
tf
.
__version__
[
0
])
>=
2
_tf_available
=
True
# pylint: disable=invalid-name
_tf_available
=
True
# pylint: disable=invalid-name
logger
.
info
(
"TensorFlow version {} available."
.
format
(
tf
.
__version__
))
logger
.
info
(
"TensorFlow version {} available."
.
format
(
tf
.
__version__
))
else
:
logger
.
info
(
"USE_TF override through env variable, disabling Tensorflow"
)
_tf_available
=
False
except
(
ImportError
,
AssertionError
):
except
(
ImportError
,
AssertionError
):
_tf_available
=
False
# pylint: disable=invalid-name
_tf_available
=
False
# pylint: disable=invalid-name
try
:
try
:
os
.
environ
.
setdefault
(
'USE_TORCH'
,
'YES'
)
os
.
environ
.
setdefault
(
'USE_TORCH'
,
'YES'
)
if
os
.
environ
[
'USE_TORCH'
].
upper
()
in
(
'1'
,
'ON'
,
'YES'
):
if
os
.
environ
[
'USE_TORCH'
].
upper
()
in
(
'1'
,
'ON'
,
'YES'
):
logger
.
info
(
"USE_TORCH override through env variable, disabling PyTorch"
)
_torch_available
=
False
else
:
import
torch
import
torch
_torch_available
=
True
# pylint: disable=invalid-name
_torch_available
=
True
# pylint: disable=invalid-name
logger
.
info
(
"PyTorch version {} available."
.
format
(
torch
.
__version__
))
logger
.
info
(
"PyTorch version {} available."
.
format
(
torch
.
__version__
))
else
:
logger
.
info
(
"USE_TORCH override through env variable, disabling PyTorch"
)
_torch_available
=
False
except
ImportError
:
except
ImportError
:
_torch_available
=
False
# pylint: disable=invalid-name
_torch_available
=
False
# pylint: disable=invalid-name
...
...
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