Skip to content

Commit

Permalink
Fix Lint for Bucketizer (#296)
Browse files Browse the repository at this point in the history
Summary:
Fix mypy Error introduced by `max_token_bucketize`

Pull Request resolved: #296

Reviewed By: NivekT

Differential Revision: D34895420

Pulled By: ejguan

fbshipit-source-id: 531210ea9e008320998231df8c3569d8ef7696fc
  • Loading branch information
ejguan authored and facebook-github-bot committed Mar 15, 2022
1 parent a78843b commit 8992d09
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions torchdata/datapipes/iter/transform/bucketbatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,18 @@ def __iter__(self) -> Iterator[DataChunk[T_co]]:
if len(buffer) == self.buffer_size:
length, token = heapq.heappop(buffer)
if batch_size + length > self.max_token_count:
yield batch
yield DataChunk(batch)
batch = []
batch_size = 0
batch.append(token)
batch_size += length
while buffer:
length, token = heapq.heappop(buffer)
if batch_size + length > self.max_token_count:
yield batch
yield DataChunk(batch)
batch = []
batch_size = 0
batch.append(token)
batch_size += length
if batch:
yield batch
yield DataChunk(batch)

0 comments on commit 8992d09

Please sign in to comment.