Fix attribute error for _gpus_arg_default loading checkpoint prior to 1.2.8 (#7043)

This commit is contained in:
Adrian Wälchli 2021-04-20 09:34:03 +02:00 committed by GitHub
parent 24248d6dd4
commit 67528c4665
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -286,6 +286,13 @@ def _gpus_allowed_type(x) -> Union[int, str]:
return int(x)
def _gpus_arg_default(x) -> Union[int, str]: # pragma: no-cover
# unused, but here for backward compatibility with old checkpoints that need to be able to
# unpickle the function from the checkpoint, as it was not filtered out in versions < 1.2.8
# see: https://github.com/PyTorchLightning/pytorch-lightning/pull/6898
pass
def _int_or_float_type(x) -> Union[int, float]:
if '.' in str(x):
return float(x)