Skip to content

Remove model.trainer call inside of dataloading mixin #7317

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 3 commits into from
May 3, 2021
Merged
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
6 changes: 3 additions & 3 deletions pytorch_lightning/trainer/data_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from abc import ABC
from copy import deepcopy
from functools import partial
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union

from torch.utils.data import BatchSampler, DataLoader, RandomSampler, SequentialSampler
from torch.utils.data.distributed import DistributedSampler
Expand Down Expand Up @@ -56,6 +56,7 @@ class TrainerDataLoadingMixin(ABC):
accelerator: Accelerator
accelerator_connector: AcceleratorConnector
dev_debugger: InternalDebugger
call_hook: Callable

def _worker_check(self, dataloader: DataLoader, name: str) -> None:
if not isinstance(dataloader, DataLoader):
Expand Down Expand Up @@ -437,8 +438,7 @@ def request_dataloader(self, model: LightningModule, stage: str) -> DataLoader:
Returns:
The dataloader
"""
if model.trainer is not None:
model.trainer.call_hook(f"on_{stage}_dataloader")
self.call_hook(f"on_{stage}_dataloader")
dataloader: DataLoader = getattr(model, f'{stage}_dataloader')()
dataloader = self._flatten_dl_only(dataloader)
self.accelerator.barrier('get_dataloaders')
Expand Down