diff --git a/backend/pyi_rth_numpy_compat.py b/backend/pyi_rth_numpy_compat.py index 683f4dea..ecf9f7a9 100644 --- a/backend/pyi_rth_numpy_compat.py +++ b/backend/pyi_rth_numpy_compat.py @@ -44,6 +44,7 @@ def _patch_torch_from_numpy(): return try: import ctypes + import numpy as np _orig = torch.from_numpy @@ -53,17 +54,17 @@ def _patch_torch_from_numpy(): # silently corrupt data (e.g. fp16 tensors from some TTS engines), # so we raise instead. dtype_map = { - "float16": _t.float16, - "float32": _t.float32, - "float64": _t.float64, - "int8": _t.int8, - "int16": _t.int16, - "int32": _t.int32, - "int64": _t.int64, - "uint8": _t.uint8, - "bool": _t.bool, - "complex64": _t.complex64, - "complex128": _t.complex128, + "float16": torch.float16, + "float32": torch.float32, + "float64": torch.float64, + "int8": torch.int8, + "int16": torch.int16, + "int32": torch.int32, + "int64": torch.int64, + "uint8": torch.uint8, + "bool": torch.bool, + "complex64": torch.complex64, + "complex128": torch.complex128, } def _safe_from_numpy(