Skip to content

Commit 534d3de

Browse files
committed
Use Literal type for viz parameter
1 parent a82f4c4 commit 534d3de

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

transformer_nuggets/utils/benchmark.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from contextlib import contextmanager, nullcontext
44
from dataclasses import dataclass, field
55
from pathlib import Path
6+
from typing import Literal
67
from collections.abc import Callable
78

89
import torch
@@ -206,7 +207,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
206207

207208

208209
@contextmanager
209-
def save_memory_snapshot(file_path: Path | str, viz: str = "torch"):
210+
def save_memory_snapshot(file_path: Path | str, viz: Literal["torch", "d3"] = "torch"):
210211
"""Save a memory snapshot information to a folder
211212
212213
Args:
@@ -288,7 +289,7 @@ def _is_distributed():
288289
def attach_oom_observer(
289290
save_path: Path | None = None,
290291
max_entries: int = 1000000,
291-
viz: str = "torch",
292+
viz: Literal["torch", "d3"] = "torch",
292293
):
293294
"""
294295
Attach an out-of-memory (OOM) observer to the CUDA device.

0 commit comments

Comments
 (0)