MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / _cast_if_autocast_enabled

Function _cast_if_autocast_enabled

inference/models/mpt.py:47–56  ·  view source on GitHub ↗
(tensor)

Source from the content-addressed store, hash-verified

45
46
47def _cast_if_autocast_enabled(tensor):
48 if torch.is_autocast_enabled():
49 if tensor.device.type == "cuda":
50 dtype = torch.get_autocast_gpu_dtype()
51 elif tensor.device.type == "cpu":
52 dtype = torch.get_autocast_cpu_dtype()
53 else:
54 raise NotImplementedError()
55 return tensor.to(dtype=dtype)
56 return tensor
57
58
59class LPLayerNorm(torch.nn.LayerNorm):

Callers 1

forwardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected