|
23 | 23 | from torch.utils.hooks import RemovableHandle |
24 | 24 |
|
25 | 25 | import pytorch_lightning as pl |
26 | | -from pytorch_lightning.utilities import AMPType, DeviceType, ModelSummaryMode, rank_zero_deprecation |
27 | | -from pytorch_lightning.utilities.exceptions import MisconfigurationException |
| 26 | +from pytorch_lightning.utilities import AMPType, DeviceType |
28 | 27 | from pytorch_lightning.utilities.imports import _TORCH_GREATER_EQUAL_1_8 |
29 | 28 | from pytorch_lightning.utilities.warnings import WarningCache |
30 | 29 |
|
@@ -130,13 +129,6 @@ class ModelSummary: |
130 | 129 |
|
131 | 130 | Args: |
132 | 131 | model: The model to summarize (also referred to as the root module). |
133 | | - mode: Can be one of |
134 | | -
|
135 | | - - `top` (default): only the top-level modules will be recorded (the children of the root module) |
136 | | - - `full`: summarizes all layers and their submodules in the root module |
137 | | -
|
138 | | - .. deprecated:: v1.4 |
139 | | - This parameter was deprecated in v1.4 in favor of `max_depth` and will be removed in v1.6. |
140 | 132 |
|
141 | 133 | max_depth: Maximum depth of modules to show. Use -1 to show all modules or 0 to show no |
142 | 134 | summary. Defaults to 1. |
@@ -186,22 +178,9 @@ class ModelSummary: |
186 | 178 | 0.530 Total estimated model params size (MB) |
187 | 179 | """ |
188 | 180 |
|
189 | | - def __init__(self, model: "pl.LightningModule", mode: Optional[str] = None, max_depth: Optional[int] = 1) -> None: |
| 181 | + def __init__(self, model: "pl.LightningModule", max_depth: int = 1) -> None: |
190 | 182 | self._model = model |
191 | 183 |
|
192 | | - # temporary mapping from mode to max_depth |
193 | | - if max_depth is None or mode is not None: |
194 | | - if mode in ModelSummaryMode.supported_types(): |
195 | | - max_depth = ModelSummaryMode.get_max_depth(mode) |
196 | | - rank_zero_deprecation( |
197 | | - "Argument `mode` in `ModelSummary` is deprecated in v1.4" |
198 | | - f" and will be removed in v1.6. Use `max_depth={max_depth}` to replicate `mode={mode}` behaviour." |
199 | | - ) |
200 | | - else: |
201 | | - raise MisconfigurationException( |
202 | | - f"`mode` can be {', '.join(ModelSummaryMode.supported_types())}, got {mode}." |
203 | | - ) |
204 | | - |
205 | 184 | if not isinstance(max_depth, int) or max_depth < -1: |
206 | 185 | raise ValueError(f"`max_depth` can be -1, 0 or > 0, got {max_depth}.") |
207 | 186 |
|
@@ -436,40 +415,16 @@ def _is_lazy_weight_tensor(p: Tensor) -> bool: |
436 | 415 | return False |
437 | 416 |
|
438 | 417 |
|
439 | | -def summarize( |
440 | | - lightning_module: "pl.LightningModule", mode: Optional[str] = None, max_depth: Optional[int] = None |
441 | | -) -> ModelSummary: |
| 418 | +def summarize(lightning_module: "pl.LightningModule", max_depth: int = 1) -> ModelSummary: |
442 | 419 | """Summarize the LightningModule specified by `lightning_module`. |
443 | 420 |
|
444 | 421 | Args: |
445 | 422 | lightning_module: `LightningModule` to summarize. |
446 | | - mode: Can be either ``'top'`` (summarize only direct submodules) or ``'full'`` (summarize all layers). |
447 | | -
|
448 | | - .. deprecated:: v1.4 |
449 | | - This parameter was deprecated in v1.4 in favor of `max_depth` and will be removed in v1.6. |
450 | 423 |
|
451 | 424 | max_depth: The maximum depth of layer nesting that the summary will include. A value of 0 turns the |
452 | 425 | layer summary off. Default: 1. |
453 | 426 |
|
454 | 427 | Return: |
455 | 428 | The model summary object |
456 | 429 | """ |
457 | | - |
458 | | - # temporary mapping from mode to max_depth |
459 | | - if max_depth is None: |
460 | | - if mode is None: |
461 | | - model_summary = ModelSummary(lightning_module, max_depth=1) |
462 | | - elif mode in ModelSummaryMode.supported_types(): |
463 | | - max_depth = ModelSummaryMode.get_max_depth(mode) |
464 | | - rank_zero_deprecation( |
465 | | - "Argument `mode` in `LightningModule.summarize` is deprecated in v1.4" |
466 | | - f" and will be removed in v1.6. Use `max_depth={max_depth}` to replicate `mode={mode}` behavior." |
467 | | - ) |
468 | | - model_summary = ModelSummary(lightning_module, max_depth=max_depth) |
469 | | - else: |
470 | | - raise MisconfigurationException( |
471 | | - f"`mode` can be None, {', '.join(ModelSummaryMode.supported_types())}, got {mode}" |
472 | | - ) |
473 | | - else: |
474 | | - model_summary = ModelSummary(lightning_module, max_depth=max_depth) |
475 | | - return model_summary |
| 430 | + return ModelSummary(lightning_module, max_depth=max_depth) |
0 commit comments