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

ensure type in cfg #1602

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
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
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
Loading