@@ -29,10 +29,10 @@ def _fc_to_af_array(in_ptr, in_shape, in_dtype, is_device=False, copy = True):
29
29
"""
30
30
res = Array (in_ptr , in_shape , in_dtype , is_device = is_device )
31
31
32
- if is_device :
33
- lock_array (res )
34
- pass
32
+ if not is_device :
33
+ return res
35
34
35
+ lock_array (res )
36
36
return res .copy () if copy else res
37
37
38
38
def _cc_to_af_array (in_ptr , ndim , in_shape , in_dtype , is_device = False , copy = True ):
@@ -41,24 +41,11 @@ def _cc_to_af_array(in_ptr, ndim, in_shape, in_dtype, is_device=False, copy = Tr
41
41
"""
42
42
if ndim == 1 :
43
43
return _fc_to_af_array (in_ptr , in_shape , in_dtype , is_device , copy )
44
- elif ndim == 2 :
45
- shape = (in_shape [1 ], in_shape [0 ])
46
- res = Array (in_ptr , shape , in_dtype , is_device = is_device )
47
- if is_device : lock_array (res )
48
- return reorder (res , 1 , 0 )
49
- elif ndim == 3 :
50
- shape = (in_shape [2 ], in_shape [1 ], in_shape [0 ])
51
- res = Array (in_ptr , shape , in_dtype , is_device = is_device )
52
- if is_device : lock_array (res )
53
- return reorder (res , 2 , 1 , 0 )
54
- elif ndim == 4 :
55
- shape = (in_shape [3 ], in_shape [2 ], in_shape [1 ], in_shape [0 ])
44
+ else :
45
+ shape = tuple (reversed (in_shape ))
56
46
res = Array (in_ptr , shape , in_dtype , is_device = is_device )
57
47
if is_device : lock_array (res )
58
- return reorder (res , 3 , 2 , 1 , 0 )
59
- else :
60
- raise RuntimeError ("Unsupported ndim" )
61
-
48
+ return res ._reorder ()
62
49
63
50
_nptype_to_aftype = {'b1' : Dtype .b8 ,
64
51
'u1' : Dtype .u8 ,
0 commit comments