Skip to content

Commit b36631a

Browse files
committed
fix: Correctly map numpy dtypes to torch dtypes in TorchWrapper
1 parent f3052d0 commit b36631a

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

torch_wrapper.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ def _map_dtype(self, dtype):
9494
return dtype
9595

9696
# Map numpy dtypes to torch dtypes
97-
if dt == np.float64: return torch.float64
98-
if dt == np.float32: return torch.float32
99-
if dt == np.float16: return torch.float16
100-
if dt == np.int64: return torch.long
101-
if dt == np.int32: return torch.int32
102-
if dt == np.int16: return torch.int16
103-
if dt == np.int8: return torch.int8
104-
if dt == np.complex128: return torch.complex128
105-
if dt == np.complex64: return torch.complex64
106-
if dt == np.bool_: return torch.bool
97+
if dt == np.dtype('float64'): return torch.float64
98+
if dt == np.dtype('float32'): return torch.float32
99+
if dt == np.dtype('float16'): return torch.float16
100+
if dt == np.dtype('int64'): return torch.long
101+
if dt == np.dtype('int32'): return torch.int32
102+
if dt == np.dtype('int16'): return torch.int16
103+
if dt == np.dtype('int8'): return torch.int8
104+
if dt == np.dtype('complex128'): return torch.complex128
105+
if dt == np.dtype('complex64'): return torch.complex64
106+
if dt == np.dtype('bool'): return torch.bool
107107

108108
return dtype
109109

0 commit comments

Comments
 (0)