@@ -24,20 +24,19 @@ def __repr__(self) -> str:
2424
2525
2626# Specification required
27- int8 = Dtype ("int8" , "i8" , ctypes .c_char , "int8" , 4 ) # HACK int8 - Not Supported, b8?
28- int16 = Dtype ("int16" , "h" , ctypes .c_short , "short int" , 10 )
29- int32 = Dtype ("int32" , "i" , ctypes .c_int , "int" , 5 )
30- int64 = Dtype ("int64" , "l" , ctypes .c_longlong , "long int" , 8 )
31- uint8 = Dtype ("uint8" , "B" , ctypes .c_ubyte , "unsigned_char" , 7 )
32- uint16 = Dtype ("uint16" , "H" , ctypes .c_ushort , "unsigned short int" , 11 )
33- uint32 = Dtype ("uint32" , "I" , ctypes .c_uint , "unsigned int" , 6 )
34- uint64 = Dtype ("uint64" , "L" , ctypes .c_ulonglong , "unsigned long int" , 9 )
35- float16 = Dtype ("float16" , "e" , ctypes .c_uint16 , "half" , 12 )
36- float32 = Dtype ("float32" , "f" , ctypes .c_float , "float" , 0 )
37- float64 = Dtype ("float64" , "d" , ctypes .c_double , "double" , 2 )
38- complex64 = Dtype ("complex64" , "F" , ctypes .c_float * 2 , "float complex" , 1 ) # type: ignore[arg-type]
39- complex128 = Dtype ("complex128" , "D" , ctypes .c_double * 2 , "double complex" , 3 ) # type: ignore[arg-type]
40- bool = Dtype ("bool" , "b" , ctypes .c_bool , "bool" , 4 )
27+ int16 = s16 = Dtype ("int16" , "h" , ctypes .c_short , "short int" , 10 )
28+ int32 = s32 = Dtype ("int32" , "i" , ctypes .c_int , "int" , 5 )
29+ int64 = s64 = Dtype ("int64" , "l" , ctypes .c_longlong , "long int" , 8 )
30+ uint8 = u8 = Dtype ("uint8" , "B" , ctypes .c_ubyte , "unsigned_char" , 7 )
31+ uint16 = u16 = Dtype ("uint16" , "H" , ctypes .c_ushort , "unsigned short int" , 11 )
32+ uint32 = u32 = Dtype ("uint32" , "I" , ctypes .c_uint , "unsigned int" , 6 )
33+ uint64 = u64 = Dtype ("uint64" , "L" , ctypes .c_ulonglong , "unsigned long int" , 9 )
34+ float16 = f16 = Dtype ("float16" , "e" , ctypes .c_uint16 , "half" , 12 )
35+ float32 = f32 = Dtype ("float32" , "f" , ctypes .c_float , "float" , 0 )
36+ float64 = f64 = Dtype ("float64" , "d" , ctypes .c_double , "double" , 2 )
37+ complex32 = c32 = Dtype ("complex64" , "F" , ctypes .c_float * 2 , "float complex" , 1 ) # type: ignore[arg-type]
38+ complex64 = c64 = Dtype ("complex128" , "D" , ctypes .c_double * 2 , "double complex" , 3 ) # type: ignore[arg-type]
39+ bool = b8 = Dtype ("bool" , "b" , ctypes .c_bool , "bool" , 4 )
4140
4241supported_dtypes = (
4342 int16 ,
@@ -51,14 +50,26 @@ def __repr__(self) -> str:
5150 float32 ,
5251 float64 ,
5352 complex64 ,
54- complex128 ,
53+ complex32 ,
5554 bool ,
56- int8 , # BUG if place on top of the list
55+ s16 ,
56+ s32 ,
57+ s64 ,
58+ u8 ,
59+ u16 ,
60+ u32 ,
61+ u64 ,
62+ f16 ,
63+ f32 ,
64+ f64 ,
65+ c32 ,
66+ c64 ,
67+ b8 ,
5768)
5869
5970
6071def is_complex_dtype (dtype : Dtype ) -> _python_bool :
61- return dtype in {complex64 , complex128 }
72+ return dtype in {complex32 , complex64 }
6273
6374
6475def to_str (c_str : ctypes .c_char_p | ctypes .Array [ctypes .c_char ]) -> str :
@@ -71,19 +82,19 @@ def implicit_dtype(number: int | float | _python_bool | complex, array_dtype: Dt
7182 elif isinstance (number , int ):
7283 number_dtype = int64
7384 elif isinstance (number , float ):
74- number_dtype = float64
85+ number_dtype = float32
7586 elif isinstance (number , complex ):
76- number_dtype = complex128
87+ number_dtype = complex64
7788 else :
7889 raise TypeError (f"{ type (number )} is not supported and can not be converted to af.Dtype." )
7990
80- if not (array_dtype == float32 or array_dtype == complex64 ):
91+ if not (array_dtype == float32 or array_dtype == complex32 ):
8192 return number_dtype
8293
8394 if number_dtype == float64 :
8495 return float32
8596
86- if number_dtype == complex128 :
97+ if number_dtype == complex64 :
8798 return complex64
8899
89100 return number_dtype
0 commit comments