We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7b30010 commit 2196fe5Copy full SHA for 2196fe5
arrayfire/interop.py
@@ -26,6 +26,18 @@
26
27
AF_NUMPY_FOUND=True
28
29
+ _nptype_to_aftype = {'f4' : Dtype.f32,
30
+ 'f8' : Dtype.f64,
31
+ 'b1' : Dtype.b8,
32
+ 'u1' : Dtype.u8,
33
+ 'i4' : Dtype.s32,
34
+ 's4' : Dtype.u32,
35
+ 'i8' : Dtype.s64,
36
+ 's8' : Dtype.u64,
37
+ 'c8' : Dtype.c32,
38
+ 'c16' : Dtype.c64}
39
+
40
41
def np_to_af_array(np_arr):
42
"""
43
Convert numpy.ndarray to arrayfire.Array.
@@ -41,7 +53,7 @@ def np_to_af_array(np_arr):
53
54
in_shape = np_arr.shape
55
in_ptr = np_arr.ctypes.data_as(ct.c_void_p)
44
- in_dtype = np_arr.dtype.char
56
+ in_dtype = _nptype_to_aftype[np_arr.dtype.str[1:]]
45
57
46
58
if (np_arr.flags['F_CONTIGUOUS']):
47
59
return Array(in_ptr, in_shape, in_dtype)
0 commit comments