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

Function _is_torch_fp16_available

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

Source from the content-addressed store, hash-verified

1183
1184# Utils for custom and alternative accelerator devices
1185def _is_torch_fp16_available(device):
1186 if not is_torch_available():
1187 return False
1188
1189 import torch
1190
1191 device = torch.device(device)
1192
1193 try:
1194 x = torch.zeros((2, 2), dtype=torch.float16).to(device)
1195 _ = torch.mul(x, x)
1196 return True
1197
1198 except Exception as e:
1199 if device.type == "cuda":
1200 raise ValueError(
1201 f"You have passed a device of type 'cuda' which should work with 'fp16', but 'cuda' does not seem to be correctly installed on your machine: {e}"
1202 )
1203
1204 return False
1205
1206
1207def _is_torch_fp64_available(device):

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…