Commit 2d3161da authored by Sergey Edunov's avatar Sergey Edunov
Browse files

Issue #2, Checking size attribute of dst when dst is None

parent a6155337
...@@ -216,7 +216,7 @@ def batches_by_size(src, batch_size=None, max_tokens=None, dst=None, max_positio ...@@ -216,7 +216,7 @@ def batches_by_size(src, batch_size=None, max_tokens=None, dst=None, max_positio
# - 2 here stems from make_positions() where we offset positions # - 2 here stems from make_positions() where we offset positions
# by padding_value + 1 # by padding_value + 1
if src.sizes[idx] < 2 or \ if src.sizes[idx] < 2 or \
(dst is not None and dst.sizes[idx] < 2) or \ (False if dst is None else dst.sizes[idx] < 2) or \
sizes[idx] > max_positions - 2: sizes[idx] > max_positions - 2:
raise Exception("Unable to handle input id {} of " raise Exception("Unable to handle input id {} of "
"size {} / {}.".format(idx, src.sizes[idx], dst.sizes[idx])) "size {} / {}.".format(idx, src.sizes[idx], dst.sizes[idx]))
......
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