mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-09-18 06:10:43 -07:00
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.
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user