Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add back timer to state #349

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions torchtnt/framework/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from typing import Any, Iterable, Optional

from torchtnt.framework.progress import Progress
from torchtnt.utils import Timer

_logger: logging.Logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -147,11 +148,13 @@ def __init__(
self,
*,
entry_point: EntryPoint,
timer: Optional[Timer] = None,
train_state: Optional[PhaseState] = None,
eval_state: Optional[PhaseState] = None,
predict_state: Optional[PhaseState] = None,
) -> None:
self._entry_point = entry_point
self._timer: Timer = timer or Timer()
self._train_state = train_state
self._eval_state = eval_state
self._predict_state = predict_state
Expand All @@ -168,6 +171,11 @@ def active_phase(self) -> ActivePhase:
"""Current active phase of the loop. (One of TRAIN, EVALUATE, PREDICT)."""
return self._active_phase

@property
def timer(self) -> Timer:
"""A :class:`~torchtnt.framework.Timer` object which records latencies of key events during loop execution."""
return self._timer

@property
def train_state(self) -> Optional[PhaseState]:
"""A :class:`~torchtnt.framework.PhaseState` object which contains meta information about the train phase."""
Expand Down