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
OpenDAS
Fairseq
Commits
c52f6ea4
"git@developer.sourcefind.cn:OpenDAS/torchaudio.git" did not exist on "e4f508a3eece3a0619fb76b195b6c6a16b4903bf"
Commit
c52f6ea4
authored
Apr 07, 2018
by
Sergey Edunov
Committed by
Myle Ott
Jun 15, 2018
Browse files
better batching
parent
d6be0c7e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
fairseq/data.py
fairseq/data.py
+7
-4
No files found.
fairseq/data.py
View file @
c52f6ea4
...
@@ -322,10 +322,13 @@ def _make_batches(src, dst, indices, max_tokens, max_sentences, max_positions,
...
@@ -322,10 +322,13 @@ def _make_batches(src, dst, indices, max_tokens, max_sentences, max_positions,
sample_len
=
max
(
sample_len
,
src_size
,
dst_size
)
sample_len
=
max
(
sample_len
,
src_size
,
dst_size
)
num_tokens
=
(
len
(
batch
)
+
1
)
*
sample_len
num_tokens
=
(
len
(
batch
)
+
1
)
*
sample_len
if
yield_batch
(
idx
,
num_tokens
):
while
yield_batch
(
idx
,
num_tokens
):
yield
batch
mod8_len
=
max
(
8
*
(
len
(
batch
)
//
8
),
len
(
batch
)
%
8
)
batch
=
[]
yield
batch
[:
mod8_len
]
sample_len
=
max
(
src_size
,
dst_size
)
batch
=
batch
[
mod8_len
:]
sample_len
=
max
([
max
(
src
.
sizes
[
id
],
dst
.
sizes
[
id
])
for
id
in
batch
])
if
len
(
batch
)
>
0
else
0
sample_len
=
max
(
sample_len
,
src_size
,
dst_size
)
num_tokens
=
(
len
(
batch
)
+
1
)
*
sample_len
batch
.
append
(
idx
)
batch
.
append
(
idx
)
...
...
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