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
7e4844fc
Unverified
Commit
7e4844fc
authored
Feb 11, 2022
by
lewtun
Committed by
GitHub
Feb 11, 2022
Browse files
Enable ONNX export when PyTorch and TensorFlow installed in the same environment (#15625)
parent
6cf06d19
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
src/transformers/onnx/features.py
src/transformers/onnx/features.py
+9
-1
No files found.
src/transformers/onnx/features.py
View file @
7e4844fc
...
@@ -303,8 +303,16 @@ class FeaturesManager:
...
@@ -303,8 +303,16 @@ class FeaturesManager:
The instance of the model.
The instance of the model.
"""
"""
# If PyTorch and TensorFlow are installed in the same environment, we
# load an AutoModel class by default
model_class
=
FeaturesManager
.
get_model_class_for_feature
(
feature
)
model_class
=
FeaturesManager
.
get_model_class_for_feature
(
feature
)
return
model_class
.
from_pretrained
(
model
)
try
:
model
=
model_class
.
from_pretrained
(
model
)
# Load TensorFlow weights in an AutoModel instance if PyTorch and
# TensorFlow are installed in the same environment
except
OSError
:
model
=
model_class
.
from_pretrained
(
model
,
from_tf
=
True
)
return
model
@
staticmethod
@
staticmethod
def
check_supported_model_or_raise
(
def
check_supported_model_or_raise
(
...
...
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