Skip to content

Commit ebda066

Browse files
Richard Wangfacebook-github-bot
authored andcommitted
add get_last_checkpoint() (#883)
Summary: Pull Request resolved: #883 function to fetch the last checkpoint Reviewed By: diego-urgell Differential Revision: D61409516 fbshipit-source-id: 72f991cc9a5a3d530bad955d125df8cb039323e7
1 parent 041ebe1 commit ebda066

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

torchtnt/utils/checkpoint.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,14 @@ def should_save_checkpoint(self, checkpoint: CheckpointPath) -> bool:
477477
self._ckpt_paths[0], mode=best_checkpoint_config.mode
478478
)
479479

480+
def get_last_checkpoint(self) -> Optional[CheckpointPath]:
481+
"""
482+
Returns last checkpoint to be added
483+
"""
484+
if len(self._ckpt_paths) == 0:
485+
return None
486+
return self._ckpt_paths[-1]
487+
480488
def append_checkpoint(self, ckpt: CheckpointPath) -> None:
481489
"""
482490
This will update the internal state to keep track of the checkpoint. This function should only be called

0 commit comments

Comments
 (0)