MCPcopy Index your code
hub / github.com/huggingface/diffusers / _is_torch_fp64_available

Function _is_torch_fp64_available

src/diffusers/utils/testing_utils.py:1207–1226  ·  view source on GitHub ↗
(device)

Source from the content-addressed store, hash-verified

1205
1206
1207def _is_torch_fp64_available(device):
1208 if not is_torch_available():
1209 return False
1210
1211 import torch
1212
1213 device = torch.device(device)
1214
1215 try:
1216 x = torch.zeros((2, 2), dtype=torch.float64).to(device)
1217 _ = torch.mul(x, x)
1218 return True
1219
1220 except Exception as e:
1221 if device.type == "cuda":
1222 raise ValueError(
1223 f"You have passed a device of type 'cuda' which should work with 'fp64', but 'cuda' does not seem to be correctly installed on your machine: {e}"
1224 )
1225
1226 return False
1227
1228
1229# Guard these lookups for when Torch is not used - alternative accelerator support is for PyTorch

Callers 1

Calls 3

is_torch_availableFunction · 0.85
deviceMethod · 0.45
toMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…