From 766c51a8a1ed8c616fd1db4360803e7eb31ad0b1 Mon Sep 17 00:00:00 2001 From: Jamie Pine Date: Sun, 26 Jul 2026 23:15:53 -0700 Subject: [PATCH] fix(backend): numpy compat hook silently failed to patch torch dtype_map referenced _t, which is only bound as a default argument on the inner function, so building the map raised NameError. The surrounding except swallowed it and returned, meaning the from_numpy fallback this hook exists for never applied in frozen builds. --- backend/pyi_rth_numpy_compat.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) 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(