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

Commit

Permalink
adapt pytorch lighting 2.0 AKA lightning
Browse files Browse the repository at this point in the history
  • Loading branch information
qmpzzpmq committed Jun 13, 2023
1 parent 928575b commit b9ce086
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
14 changes: 10 additions & 4 deletions nni/compression/pytorch/utils/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@
from torch.utils.hooks import RemovableHandle

try:
import pytorch_lightning as pl
from pytorch_lightning.callbacks import Callback
import lightning as pl
from lightning.callbacks import Callback
except ImportError:
LIGHTNING_INSTALLED = False
try:
import pytorch_lightning as pl
from pytorch_lightning.callbacks import Callback
except ImportError:
LIGHTNING_INSTALLED = False
else:
LIGHTNING_INSTALLED = True
else:
LIGHTNING_INSTALLED = True

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

def get_dummy_input(self) -> Any:
return self.dummy_input
return self.dummy_input
13 changes: 10 additions & 3 deletions nni/contrib/compression/utils/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@
from torch.utils.hooks import RemovableHandle

try:
import pytorch_lightning as pl
import lightning as pl
from lightning.callbacks import Callback
except ImportError:
LIGHTNING_INSTALLED = False
try:
import pytorch_lightning as pl
from pytorch_lightning.callbacks import Callback
except ImportError:
LIGHTNING_INSTALLED = False
else:
LIGHTNING_INSTALLED = True
else:
LIGHTNING_INSTALLED = True

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

def get_dummy_input(self) -> Any:
return self.dummy_input
return self.dummy_input

0 comments on commit b9ce086

Please sign in to comment.