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
ddbb485c
Unverified
Commit
ddbb485c
authored
Feb 28, 2022
by
Patrick von Platen
Committed by
GitHub
Feb 28, 2022
Browse files
[TF-PT-Tests] Fix PyTorch - TF tests for different GPU devices (#15846)
parent
97f9b8a2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
3 deletions
+2
-3
tests/test_modeling_common.py
tests/test_modeling_common.py
+2
-3
No files found.
tests/test_modeling_common.py
View file @
ddbb485c
...
@@ -1493,9 +1493,8 @@ class ModelTesterMixin:
...
@@ -1493,9 +1493,8 @@ class ModelTesterMixin:
tf_model
=
transformers
.
load_pytorch_model_in_tf2_model
(
tf_model
,
pt_model
,
tf_inputs
=
tf_inputs_dict
)
tf_model
=
transformers
.
load_pytorch_model_in_tf2_model
(
tf_model
,
pt_model
,
tf_inputs
=
tf_inputs_dict
)
pt_model
=
transformers
.
load_tf2_model_in_pytorch_model
(
pt_model
,
tf_model
).
to
(
torch_device
)
pt_model
=
transformers
.
load_tf2_model_in_pytorch_model
(
pt_model
,
tf_model
).
to
(
torch_device
)
# need to rename encoder-decoder "inputs" for PyTorch
# Make sure PyTorch tensors are on same device as model
# if "inputs" in pt_inputs_dict and self.is_encoder_decoder:
pt_inputs
=
{
k
:
v
.
to
(
torch_device
)
if
torch
.
is_tensor
(
v
)
else
v
for
k
,
v
in
pt_inputs
.
items
()}
# pt_inputs_dict["input_ids"] = pt_inputs_dict.pop("inputs")
with
torch
.
no_grad
():
with
torch
.
no_grad
():
pto
=
pt_model
(
**
pt_inputs
)
pto
=
pt_model
(
**
pt_inputs
)
...
...
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