Skip to content

Commit

Permalink
Update on "Add Optimizer state_dict hooks"
Browse files Browse the repository at this point in the history
[ghstack-poisoned]
  • Loading branch information
janeyx99 committed Jul 27, 2023
2 parents 7c27564 + 77b0541 commit 28e5de6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions torch/optim/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Callable,
DefaultDict,
Dict,
OrderedDict,
Hashable,
Iterable,
List,
Expand Down Expand Up @@ -232,10 +231,10 @@ class Optimizer:

_optimizer_step_pre_hooks: Dict[int, OptimizerPreHook]
_optimizer_step_post_hooks: Dict[int, OptimizerPostHook]
_optimizer_state_dict_pre_hooks: OrderedDict[int, Callable[["Optimizer"], None]]
_optimizer_state_dict_post_hooks: OrderedDict[int, Callable[["Optimizer", StateDict], Optional[StateDict]]]
_optimizer_load_state_dict_pre_hooks: OrderedDict[int, Callable[["Optimizer", StateDict], Optional[StateDict]]]
_optimizer_load_state_dict_post_hooks: OrderedDict[int, Callable[["Optimizer"], None]]
_optimizer_state_dict_pre_hooks: 'OrderedDict[int, Callable[["Optimizer"], None]]'
_optimizer_state_dict_post_hooks: 'OrderedDict[int, Callable[["Optimizer", StateDict], Optional[StateDict]]]'
_optimizer_load_state_dict_pre_hooks: 'OrderedDict[int, Callable[["Optimizer", StateDict], Optional[StateDict]]]'
_optimizer_load_state_dict_post_hooks: 'OrderedDict[int, Callable[["Optimizer"], None]]'

def __init__(self, params: params_t, defaults: Dict[str, Any]) -> None:
torch._C._log_api_usage_once("python.optimizer")
Expand Down Expand Up @@ -600,7 +599,7 @@ def register_load_state_dict_pre_hook(
:meth:`~torch.optim.Optimizer.load_state_dict` is called. It should have the
following signature::
hook(optimizer, state_dict) -> None or state_dict
hook(optimizer, state_dict) -> state_dict or None
The ``optimizer`` argument is the optimizer instance being used and the
``state_dict`` argument is a shallow copy of the ``state_dict`` the user
Expand Down

0 comments on commit 28e5de6

Please sign in to comment.