Skip to content

Commit 1e32ebf

Browse files
farhadrghpre-commit-ci[bot]lantiga
authored
Fix UnboundLocalError when using the predict method with return_predictions=False. (#20484)
* any_on_epoch referenced before assignment * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Luca Antiga <luca.antiga@gmail.com>
1 parent 601c060 commit 1e32ebf

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/lightning/pytorch/loops/prediction_loop.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,9 @@ def _predict_step(
233233

234234
self.batch_progress.increment_ready()
235235

236-
if not using_dataloader_iter:
237-
any_on_epoch = self._store_data_for_prediction_writer(batch_idx, dataloader_idx)
236+
any_on_epoch = (
237+
self._store_data_for_prediction_writer(batch_idx, dataloader_idx) if not using_dataloader_iter else False
238+
)
238239

239240
# the `_step` methods don't take a batch_idx when `dataloader_iter` is used, but all other hooks still do,
240241
# so we need different kwargs

0 commit comments

Comments
 (0)