@@ -64,6 +64,8 @@ def asnumpy(self, a):
6464 def zeros (self , shape , dtype = float ):
6565 # Default to float (float64) to match dict(numpy)
6666 t_dtype = self ._get_dtype (dtype )
67+ # DEBUG
68+ print (f"DEBUG: TorchWrapper.zeros requested dtype={ dtype } mapped to { t_dtype } on device { self .device } " )
6769 return torch .zeros (shape , device = self .device , dtype = t_dtype )
6870
6971 def ones (self , shape , dtype = float ):
@@ -79,11 +81,20 @@ def _map_dtype(self, dtype):
7981 if dtype == int : return torch .long
8082 if dtype == float : return torch .float64
8183 if dtype == complex : return torch .complex128
84+ # Handle pure numpy types if passed
85+ if dtype == np .float64 : return torch .float64
86+ if dtype == np .float32 : return torch .float32
87+ if dtype == np .int64 : return torch .long
88+ if dtype == np .int32 : return torch .int32
89+ if dtype == np .complex128 : return torch .complex128
90+ if dtype == np .complex64 : return torch .complex64
8291 return dtype
8392
8493 def _get_dtype (self , dtype ):
8594 t_dtype = self ._map_dtype (dtype )
86- return self ._apply_device_constraints (t_dtype )
95+ res = self ._apply_device_constraints (t_dtype )
96+ # print(f"DEBUG: _get_dtype({dtype}) -> mapped {t_dtype} -> constrained {res}")
97+ return res
8798
8899 def _apply_device_constraints (self , dtype ):
89100 if self .device .type == 'mps' :
0 commit comments