Skip to content

remove LightningModule.summarize #12559

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

Merged
merged 5 commits into from
Apr 2, 2022
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Removed

- Removed the deprecated `summarize` method from the `LightningModule` ([#12559](https://github.com/PyTorchLightning/pytorch-lightning/pull/12559))


- Removed the deprecated `stochastic_weight_avg` argument from the `Trainer` constructor ([#12535](https://github.com/PyTorchLightning/pytorch-lightning/pull/12535))


Expand Down
23 changes: 0 additions & 23 deletions pytorch_lightning/core/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
from pytorch_lightning.utilities.distributed import distributed_available, sync_ddp
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from pytorch_lightning.utilities.memory import get_model_size_mb
from pytorch_lightning.utilities.model_summary import ModelSummary, summarize
from pytorch_lightning.utilities.parsing import collect_init_args
from pytorch_lightning.utilities.rank_zero import rank_zero_debug, rank_zero_deprecation, rank_zero_warn
from pytorch_lightning.utilities.signature_utils import is_param_in_hook_signature
Expand Down Expand Up @@ -1706,28 +1705,6 @@ def tbptt_split_batch(self, batch, split_size):

return splits

def summarize(self, max_depth: int = 1) -> ModelSummary:
"""Summarize this LightningModule.

.. deprecated:: v1.5
This method was deprecated in v1.5 in favor of `pytorch_lightning.utilities.model_summary.summarize`
and will be removed in v1.7.

Args:
max_depth: The maximum depth of layer nesting that the summary will include. A value of 0 turns the
layer summary off. Default: 1.

Return:
The model summary object
"""
rank_zero_deprecation(
"The `LightningModule.summarize` method is deprecated in v1.5 and will be removed in v1.7. "
"Use `pytorch_lightning.utilities.model_summary.summarize` instead.",
stacklevel=6,
)

return summarize(self, max_depth)

def freeze(self) -> None:
r"""
Freeze all params for inference.
Expand Down
6 changes: 0 additions & 6 deletions tests/deprecated_api/test_remove_1-7.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@
from tests.plugins.environments.test_lsf_environment import _make_rankfile


def test_v1_7_0_deprecated_lightning_module_summarize(tmpdir):
model = BoringModel()
with pytest.deprecated_call(match="The `LightningModule.summarize` method is deprecated in v1.5"):
model.summarize(max_depth=1)


def test_v1_7_0_moved_model_summary_and_layer_summary(tmpdir):
_soft_unimport_module("pytorch_lightning.core.memory")
with pytest.deprecated_call(match="to `pytorch_lightning.utilities.model_summary` since v1.5"):
Expand Down
1 change: 0 additions & 1 deletion tests/trainer/logging_/test_logger_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ def test_fx_validator_integration(tmpdir):
"on_save_checkpoint": "You can't",
"on_load_checkpoint": "You can't",
"on_exception": "You can't",
"summarize": "not managed by the `Trainer",
}
model = HookedModel(not_supported)

Expand Down