MCPcopy
hub / github.com/huggingface/diffusers / _is_torch_fp64_available

Function _is_torch_fp64_available

tests/testing_utils.py:1411–1430  ·  view source on GitHub ↗
(device)

Source from the content-addressed store, hash-verified

1409
1410
1411def _is_torch_fp64_available(device):
1412 if not is_torch_available():
1413 return False
1414
1415 import torch
1416
1417 device = torch.device(device)
1418
1419 try:
1420 x = torch.zeros((2, 2), dtype=torch.float64).to(device)
1421 _ = torch.mul(x, x)
1422 return True
1423
1424 except Exception as e:
1425 if device.type == "cuda":
1426 raise ValueError(
1427 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}"
1428 )
1429
1430 return False
1431
1432
1433# Guard these lookups for when Torch is not used - alternative accelerator support is for PyTorch

Callers 1

Calls 3

is_torch_availableFunction · 0.90
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…