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

Commit b9ce086

Browse files
committed
adapt pytorch lighting 2.0 AKA lightning
1 parent 928575b commit b9ce086

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

Diff for: nni/compression/pytorch/utils/evaluator.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@
1414
from torch.utils.hooks import RemovableHandle
1515

1616
try:
17-
import pytorch_lightning as pl
18-
from pytorch_lightning.callbacks import Callback
17+
import lightning as pl
18+
from lightning.callbacks import Callback
1919
except ImportError:
20-
LIGHTNING_INSTALLED = False
20+
try:
21+
import pytorch_lightning as pl
22+
from pytorch_lightning.callbacks import Callback
23+
except ImportError:
24+
LIGHTNING_INSTALLED = False
25+
else:
26+
LIGHTNING_INSTALLED = True
2127
else:
2228
LIGHTNING_INSTALLED = True
2329

@@ -957,4 +963,4 @@ def evaluate(self) -> float | None | Tuple[float, Dict[str, Any]] | Tuple[None,
957963
return self.trainer.evaluate()
958964

959965
def get_dummy_input(self) -> Any:
960-
return self.dummy_input
966+
return self.dummy_input

Diff for: nni/contrib/compression/utils/evaluator.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@
1616
from torch.utils.hooks import RemovableHandle
1717

1818
try:
19-
import pytorch_lightning as pl
19+
import lightning as pl
20+
from lightning.callbacks import Callback
2021
except ImportError:
21-
LIGHTNING_INSTALLED = False
22+
try:
23+
import pytorch_lightning as pl
24+
from pytorch_lightning.callbacks import Callback
25+
except ImportError:
26+
LIGHTNING_INSTALLED = False
27+
else:
28+
LIGHTNING_INSTALLED = True
2229
else:
2330
LIGHTNING_INSTALLED = True
2431

@@ -1099,4 +1106,4 @@ def evaluate(self) -> Tuple[float | None, Dict[str, Any]]:
10991106
return nni_used_metric, metric
11001107

11011108
def get_dummy_input(self) -> Any:
1102-
return self.dummy_input
1109+
return self.dummy_input

0 commit comments

Comments
 (0)