(device)
| 849 | |
| 850 | |
| 851 | def _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 |
no test coverage detected