Add hpu_utils

This commit is contained in:
PiotrBLL 2024-10-31 13:56:55 +01:00
parent 9269b2ac35
commit 52062dd798

15
whisper/hpu_utils.py Normal file
View File

@ -0,0 +1,15 @@
import warnings
import torch
def load_default_hpu() -> str:
"""
Load HPU if available, otherwise use CUDA or CPU.
"""
if not torch.hpu.is_available():
warnings.warn("HPU is not available; trying to use CUDA instead.")
return "cuda" if torch.cuda.is_available() else "cpu"
return "hpu"