Remove nested directory: BitTransformerLM/bit_transformer/torch_utils.py
Browse files
BitTransformerLM/bit_transformer/torch_utils.py
DELETED
|
@@ -1,21 +0,0 @@
|
|
| 1 |
-
from __future__ import annotations
|
| 2 |
-
|
| 3 |
-
from contextlib import contextmanager
|
| 4 |
-
import torch
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
@contextmanager
|
| 8 |
-
def cpu_autocast(enabled: bool = True):
|
| 9 |
-
"""Context manager for bfloat16 autocast on CPU.
|
| 10 |
-
|
| 11 |
-
Parameters
|
| 12 |
-
----------
|
| 13 |
-
enabled: bool, default True
|
| 14 |
-
Whether to enable autocast. When ``False`` this context manager
|
| 15 |
-
behaves like a no-op.
|
| 16 |
-
"""
|
| 17 |
-
if enabled:
|
| 18 |
-
with torch.amp.autocast(device_type="cpu", dtype=torch.bfloat16):
|
| 19 |
-
yield
|
| 20 |
-
else:
|
| 21 |
-
yield
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|