Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
-


- Avoid the deprecated `onnx.export(example_outputs=...)` in torch 1.10 ([#11116](https://github.com/PyTorchLightning/pytorch-lightning/pull/11116))



- Fixed an issue when torch-scripting a `LightningModule` after training with `Trainer(sync_batchnorm=True)` ([#11078](https://github.com/PyTorchLightning/pytorch-lightning/pull/11078))


Expand Down
2 changes: 1 addition & 1 deletion pytorch_lightning/core/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -1807,7 +1807,7 @@ def to_onnx(self, file_path: Union[str, Path], input_sample: Optional[Any] = Non

input_sample = self._apply_batch_transfer_handler(input_sample)

if "example_outputs" not in kwargs:
if not _TORCH_GREATER_EQUAL_1_10 and "example_outputs" not in kwargs:
self.eval()
if isinstance(input_sample, Tuple):
kwargs["example_outputs"] = self(*input_sample)
Expand Down
1 change: 1 addition & 0 deletions tests/models/test_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_model_saves_on_gpu(tmpdir):
assert os.path.getsize(file_path) > 4e2


@RunIf(max_torch="1.10")
def test_model_saves_with_example_output(tmpdir):
"""Test that ONNX model saves when provided with example output."""
model = BoringModel()
Expand Down