Skip to content

Commit

Permalink
[Enhance] ensure type in cfg (open-mmlab#1602)
Browse files Browse the repository at this point in the history
* ensure type in cfg

* change import level
  • Loading branch information
tenacioustommy authored Nov 6, 2024
1 parent 2e0ab7a commit 9124ebf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mmengine/optim/optimizer/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def register_torch_optimizers() -> List[str]:
torch.optim.Optimizer):
if module_name == 'Adafactor':
OPTIMIZERS.register_module(
name='torch_Adafactor', module=_optim)
name='TorchAdafactor', module=_optim)
else:
OPTIMIZERS.register_module(module=_optim)
torch_optimizers.append(module_name)
Expand Down
9 changes: 5 additions & 4 deletions mmengine/registry/build_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,12 @@ def build_optimizer_from_cfg(
cfg: Union[dict, ConfigDict, Config],
registry: Registry,
default_args: Optional[Union[dict, ConfigDict, Config]] = None) -> Any:
if 'Adafactor' == cfg['type'] and digit_version(
torch.__version__) >= digit_version('2.5.0'):
from ..logging import print_log
from ..logging import print_log
if 'type' in cfg \
and 'Adafactor' == cfg['type'] \
and digit_version(torch.__version__) >= digit_version('2.5.0'):
print_log(
'the torch version of Adafactor is registered as torch_Adafactor')
'the torch version of Adafactor is registered as TorchAdafactor')
return build_from_cfg(cfg, registry, default_args)


Expand Down

0 comments on commit 9124ebf

Please sign in to comment.