Commit 1551bf13 authored by Peizhao Zhang's avatar Peizhao Zhang Committed by Facebook GitHub Bot
Browse files

make sure the return result is consistent for ResultCache

Summary:
Pull Request resolved: https://github.com/facebookresearch/d2go/pull/376

Make sure the return result is consistent for ResultCache
* When gather = True, it will always return a list.

Reviewed By: itomatik

Differential Revision: D39874274

fbshipit-source-id: ce042261432cdce5544d10b2d4b88f5e2d0d1b68
parent 9215e1a8
...@@ -80,11 +80,11 @@ class ResultCache(object): ...@@ -80,11 +80,11 @@ class ResultCache(object):
gather (bool): gather cache results arcoss ranks to a list gather (bool): gather cache results arcoss ranks to a list
""" """
if self.cache_file is None or not PathManager.exists(self.cache_file): if self.cache_file is None or not PathManager.exists(self.cache_file):
return None ret = None
else:
with PathManager.open(self.cache_file, "rb") as fp: with PathManager.open(self.cache_file, "rb") as fp:
ret = torch.load(fp) ret = torch.load(fp)
logger.info(f"Loaded from checkpoint {self.cache_file}") logger.info(f"Loaded from checkpoint {self.cache_file}")
if gather: if gather:
ret = comm.all_gather(ret) ret = comm.all_gather(ret)
......
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