Is the use of data methods on LightningModule standard?
It took me quite some time playing with PyTorch Lightning and reading through the docs before I realized I can attach the data-related methods ([train|val]_dataloader, prepare_data) directly to LightningModule and then pass only the module to the trainer, rather than having to create a separate LightningDataModule class or passing the data loaders explicitly. When thinking of LightningModule as a task, rather than a model, this makes actually perfect sense. After all, things like batch size and learning rate are inherently related. But since I haven't seen it really explicitly documented, I wonder whether the use of data methods directly on the LightningModule is considered standard?
Hi, could you explain what you mean by

I realized I can attach the data-related methods ([train|val]_dataloader, prepare_data) directly to LightningModule

Do you mean dynamically bind the dataloader method of datamodule to lightning module?
I would not personally recommend that because it can be harder to read and debug, especially if your LightningModule also defines dataloader methods that you may expect to run in a different context.
I recommend passing the datamodule/dataloader into the fit function like so:
trainer.fit(model, datamodule=datamodule)
# or
trainer.fit(model, train_dataloader=...)
Then it will be clear to any reader that the datamodule loaders are used for training.