MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / tf32_mode

Function tf32_mode

k_diffusion/utils.py:430–444  ·  view source on GitHub ↗

A context manager that sets whether TF32 is allowed on cuDNN or matmul.

(cudnn=None, matmul=None)

Source from the content-addressed store, hash-verified

428
429@contextmanager
430def 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
447def get_safetensors_metadata(path):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected