Commit 89a69616 authored by Liezl Puzon's avatar Liezl Puzon Committed by Facebook Github Bot
Browse files

Add more details in error message when sentence length > max tokens (#672)

Summary:
Pull Request resolved: https://github.com/pytorch/fairseq/pull/672

title

Reviewed By: jmp84, pipibjc

Differential Revision: D15094977

fbshipit-source-id: c24e4ec9355b53e1585ac4da32809f1c339c7364
parent 121877f5
......@@ -156,7 +156,10 @@ def batch_by_size(
for idx in indices:
sample_lens.append(num_tokens_fn(idx))
sample_len = max(sample_len, sample_lens[-1])
assert sample_len <= max_tokens, "sentence at index {idx} exceeds max_tokens limit!".format(idx=idx)
assert sample_len <= max_tokens, (
f"sentence at index {idx} of size {sample_len} exceeds max_tokens "
f"limit of {max_tokens}!"
)
num_tokens = (len(batch) + 1) * sample_len
if is_batch_full(num_tokens):
mod_len = max(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment