MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / _is_torch_fp64_available

Function _is_torch_fp64_available

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

Source from the content-addressed store, hash-verified

849
850
851def _is_torch_fp64_available(device):
852 if not is_torch_available():
853 return False
854
855 import torch
856
857 device = torch.device(device)
858
859 try:
860 x = torch.zeros((2, 2), dtype=torch.float64).to(device)
861 _ = torch.mul(x, x)
862 return True
863
864 except Exception as e:
865 if device.type == "cuda":
866 raise ValueError(
867 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}"
868 )
869
870 return False
871
872
873# 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