Skip to content

Commit 3d5c3d2

Browse files
authored
Remove unused auto_collect_arguments class method (#14015)
1 parent a4e4cab commit 3d5c3d2

File tree

2 files changed

+1
-31
lines changed

2 files changed

+1
-31
lines changed

src/pytorch_lightning/core/module.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"""The LightningModule - an nn.Module with many additional features."""
1515

1616
import collections.abc
17-
import inspect
1817
import logging
1918
import numbers
2019
import os
@@ -46,7 +45,6 @@
4645
from pytorch_lightning.utilities.distributed import distributed_available, sync_ddp
4746
from pytorch_lightning.utilities.exceptions import MisconfigurationException
4847
from pytorch_lightning.utilities.imports import _TORCH_GREATER_EQUAL_1_11, _TORCH_GREATER_EQUAL_1_13
49-
from pytorch_lightning.utilities.parsing import collect_init_args
5048
from pytorch_lightning.utilities.rank_zero import rank_zero_debug, rank_zero_deprecation, rank_zero_warn
5149
from pytorch_lightning.utilities.signature_utils import is_param_in_hook_signature
5250
from pytorch_lightning.utilities.types import _METRIC_COLLECTION, EPOCH_OUTPUT, LRSchedulerTypeUnion, STEP_OUTPUT
@@ -1782,34 +1780,6 @@ def _verify_is_manual_optimization(self, fn_name):
17821780
" set model property `automatic_optimization` as False"
17831781
)
17841782

1785-
@classmethod
1786-
def _auto_collect_arguments(cls, frame=None) -> Tuple[Dict, Dict]:
1787-
"""Collect all module arguments in the current constructor and all child constructors. The child
1788-
constructors are all the ``__init__`` methods that reach the current class through (chained)
1789-
``super().__init__()`` calls.
1790-
1791-
Args:
1792-
frame: instance frame
1793-
1794-
Returns:
1795-
self_arguments: arguments dictionary of the first instance
1796-
parents_arguments: arguments dictionary of the parent's instances
1797-
"""
1798-
if not frame:
1799-
frame = inspect.currentframe()
1800-
1801-
frame_args = collect_init_args(frame.f_back, [])
1802-
self_arguments = frame_args[-1]
1803-
1804-
# set hyper_parameters in child
1805-
self_arguments = self_arguments
1806-
parents_arguments = {}
1807-
1808-
# add all arguments from parents
1809-
for args in frame_args[:-1]:
1810-
parents_arguments.update(args)
1811-
return self_arguments, parents_arguments
1812-
18131783
@torch.no_grad()
18141784
def to_onnx(self, file_path: Union[str, Path], input_sample: Optional[Any] = None, **kwargs):
18151785
"""Saves the model in ONNX format.

tests/tests_pytorch/models/test_hparams.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def __init__(self, arg1, arg2, *args, **kwargs):
410410

411411

412412
class LocalVariableModelSuperFirst(BoringModel):
413-
"""This model has the _auto_collect_arguments() call at the end."""
413+
"""This model has the save_hyperparameters() call at the end."""
414414

415415
def __init__(self, arg1, arg2, *args, **kwargs):
416416
super().__init__(*args, **kwargs)

0 commit comments

Comments
 (0)