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
a21ee1f9
"docs/source/vscode:/vscode.git/clone" did not exist on "af69360bf96946e6d4d321d96ec7dea991c5cbbf"
Unverified
Commit
a21ee1f9
authored
Sep 28, 2021
by
Sylvain Gugger
Committed by
GitHub
Sep 28, 2021
Browse files
Implement len in IterableDatasetShard (#13780)
parent
83d3dc0f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
src/transformers/trainer_pt_utils.py
src/transformers/trainer_pt_utils.py
+7
-0
No files found.
src/transformers/trainer_pt_utils.py
View file @
a21ee1f9
...
@@ -772,6 +772,13 @@ class IterableDatasetShard(IterableDataset):
...
@@ -772,6 +772,13 @@ class IterableDatasetShard(IterableDataset):
for
i
in
process_slice
:
for
i
in
process_slice
:
yield
current_batch
[
i
]
yield
current_batch
[
i
]
def
__len__
(
self
):
# Will raise an error if the underlying dataset is not sized.
if
self
.
drop_last
:
return
len
(
self
.
dataset
)
//
self
.
num_processes
else
:
return
math
.
ceil
(
len
(
self
.
dataset
)
/
self
.
num_processes
)
# In order to keep `trainer.py` compact and easy to understand, place any secondary PT Trainer
# In order to keep `trainer.py` compact and easy to understand, place any secondary PT Trainer
# helper methods here
# helper methods here
...
...
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