Skip to content

Commit 712c4b1

Browse files
author
yicongd
committed
add typing to utilities/memory.py
1 parent f41d1e5 commit 712c4b1

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ module = [
9696
"pytorch_lightning.utilities.data",
9797
"pytorch_lightning.utilities.distributed",
9898
"pytorch_lightning.utilities.fetching",
99-
"pytorch_lightning.utilities.memory",
10099
"pytorch_lightning.utilities.meta",
101100
]
102101
ignore_errors = "True"

pytorch_lightning/utilities/memory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import os
1818
import shutil
1919
import subprocess
20-
from typing import Any, Dict
20+
from typing import Any, cast, Dict, IO
2121

2222
import torch
2323
from torch.nn import Module
@@ -184,6 +184,6 @@ def get_model_size_mb(model: Module) -> float:
184184
Number of megabytes in the parameters of the input module.
185185
"""
186186
model_size = _ByteCounter()
187-
torch.save(model.state_dict(), model_size)
187+
torch.save(model.state_dict(), cast(IO[bytes], model_size))
188188
size_mb = model_size.nbytes / 1e6
189189
return size_mb

0 commit comments

Comments
 (0)