A context manager that sets whether TF32 is allowed on cuDNN or matmul.
(cudnn=None, matmul=None)
| 428 | |
| 429 | @contextmanager |
| 430 | def tf32_mode(cudnn=None, matmul=None): |
| 431 | """A context manager that sets whether TF32 is allowed on cuDNN or matmul.""" |
| 432 | cudnn_old = torch.backends.cudnn.allow_tf32 |
| 433 | matmul_old = torch.backends.cuda.matmul.allow_tf32 |
| 434 | try: |
| 435 | if cudnn is not None: |
| 436 | torch.backends.cudnn.allow_tf32 = cudnn |
| 437 | if matmul is not None: |
| 438 | torch.backends.cuda.matmul.allow_tf32 = matmul |
| 439 | yield |
| 440 | finally: |
| 441 | if cudnn is not None: |
| 442 | torch.backends.cudnn.allow_tf32 = cudnn_old |
| 443 | if matmul is not None: |
| 444 | torch.backends.cuda.matmul.allow_tf32 = matmul_old |
| 445 | |
| 446 | |
| 447 | def get_safetensors_metadata(path): |
nothing calls this directly
no outgoing calls
no test coverage detected