Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Catch exception from ONNX conversion #4034

Merged
merged 1 commit into from
Aug 9, 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
5 changes: 4 additions & 1 deletion nni/retiarii/evaluator/pytorch/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ def validation_step(self, batch, batch_idx):
y_hat = self(x)

if not self._already_exported:
self.to_onnx(self.export_onnx, x, export_params=True)
try:
self.to_onnx(self.export_onnx, x, export_params=True)
except RuntimeError as e:
warnings.warn(f'ONNX conversion failed. As a result, you might not be able to use visualization. Error message: {e}')
Copy link
Contributor

@chenbohua3 chenbohua3 Aug 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when fail to export onnx, does self._already_exported should be False?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't try to export again.

self._already_exported = True

self.log('val_loss', self.criterion(y_hat, y), prog_bar=True)
Expand Down