Commit 2bf7e75d authored by Taylan Bilal's avatar Taylan Bilal Committed by Facebook Github Bot
Browse files

add __len__ for progress_bar (#871)

Summary:
We need this so that `progress_bar`s work with pytorch/xla i.e. TPUs. See [here](https://github.com/pytorch/xla/blob/master/torch_xla_py/data_parallel.py#L130).
Pull Request resolved: https://github.com/pytorch/fairseq/pull/871

Differential Revision: D16181062

Pulled By: myleott

fbshipit-source-id: 02c65033260396c2a243fbb66e31ffc2965f2376
parent e4335001
...@@ -80,6 +80,9 @@ class progress_bar(object): ...@@ -80,6 +80,9 @@ class progress_bar(object):
if prefix is not None: if prefix is not None:
self.prefix += ' | {}'.format(prefix) self.prefix += ' | {}'.format(prefix)
def __len__(self):
return len(self.iterable)
def __enter__(self): def __enter__(self):
return self return self
......
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