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
c1cda0ee
Unverified
Commit
c1cda0ee
authored
Jul 08, 2024
by
Dingli Yang
Committed by
GitHub
Jul 08, 2024
Browse files
Fix Seq2SeqTrainer crash when BatchEncoding data is None (#31418)
avoiding crash when BatchEncoding data is None
parent
06fd7972
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
src/transformers/tokenization_utils_base.py
src/transformers/tokenization_utils_base.py
+1
-1
No files found.
src/transformers/tokenization_utils_base.py
View file @
c1cda0ee
...
...
@@ -800,7 +800,7 @@ class BatchEncoding(UserDict):
# Otherwise it passes the casts down and casts the LongTensor containing the token idxs
# into a HalfTensor
if
isinstance
(
device
,
str
)
or
is_torch_device
(
device
)
or
isinstance
(
device
,
int
):
self
.
data
=
{
k
:
v
.
to
(
device
=
device
)
for
k
,
v
in
self
.
data
.
items
()}
self
.
data
=
{
k
:
v
.
to
(
device
=
device
)
for
k
,
v
in
self
.
data
.
items
()
if
v
is
not
None
}
else
:
logger
.
warning
(
f
"Attempting to cast a BatchEncoding to type
{
str
(
device
)
}
. This is not supported."
)
return
self
...
...
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