Skip to content

Commit

Permalink
add get_last_checkpoint() (#883)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #883

function to fetch the last checkpoint

Reviewed By: diego-urgell

Differential Revision: D61409516
  • Loading branch information
Richard Wang authored and facebook-github-bot committed Aug 19, 2024
1 parent 041ebe1 commit b743077
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions torchtnt/utils/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,14 @@ def should_save_checkpoint(self, checkpoint: CheckpointPath) -> bool:
self._ckpt_paths[0], mode=best_checkpoint_config.mode
)

def get_last_checkpoint(self) -> Optional[CheckpointPath]:
"""
Returns last checkpoint to be added
"""
if len(self._ckpt_paths) == 0:
return None
return self._ckpt_paths[-1]

def append_checkpoint(self, ckpt: CheckpointPath) -> None:
"""
This will update the internal state to keep track of the checkpoint. This function should only be called
Expand Down

0 comments on commit b743077

Please sign in to comment.