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
c54af4c7
Unverified
Commit
c54af4c7
authored
Jul 11, 2024
by
haikuoxin
Committed by
GitHub
Jul 10, 2024
Browse files
Add a condition for nested_detach (#31855)
fix bug:
https://github.com/huggingface/transformers/issues/31852
parent
080e14b2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
src/transformers/trainer_pt_utils.py
src/transformers/trainer_pt_utils.py
+1
-1
No files found.
src/transformers/trainer_pt_utils.py
View file @
c54af4c7
...
...
@@ -192,7 +192,7 @@ def nested_detach(tensors):
return
type
(
tensors
)(
nested_detach
(
t
)
for
t
in
tensors
)
elif
isinstance
(
tensors
,
Mapping
):
return
type
(
tensors
)({
k
:
nested_detach
(
t
)
for
k
,
t
in
tensors
.
items
()})
return
tensors
.
detach
()
return
tensors
.
detach
()
if
isinstance
(
tensors
,
torch
.
Tensor
)
else
tensors
def
nested_xla_mesh_reduce
(
tensors
,
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