dpnp.asfortranarray
- dpnp.asfortranarray(a, dtype=None, *, like=None, device=None, usm_type=None, sycl_queue=None)[source]
Return an array
(ndim >= 1)
laid out in Fortran order in memory.For full documentation refer to
numpy.asfortranarray
.- Parameters:
a (array_like) -- Input data, in any form that can be converted to an array. This includes scalars, lists, lists of tuples, tuples, tuples of tuples, tuples of lists, and ndarrays.
dtype ({None, dtype}, optional) -- The desired dtype for the array. If not given, a default dtype will be used that can represent the values (by considering Promotion Type Rule and device capabilities when necessary).
device ({None, string, SyclDevice, SyclQueue}, optional) -- An array API concept of device where the output array is created. The device can be
None
(the default), an OneAPI filter selector string, an instance ofdpctl.SyclDevice
corresponding to a non-partitioned SYCL device, an instance ofdpctl.SyclQueue
, or a Device object returned bydpnp.dpnp_array.dpnp_array.device
property.usm_type ({None, "device", "shared", "host"}, optional) -- The type of SYCL USM allocation for the output array. Default:
None
.sycl_queue ({None, SyclQueue}, optional) -- A SYCL queue to use for output array allocation and copying. The sycl_queue can be passed as
None
(the default), which means to get the SYCL queue from device keyword if present or to use a default queue. Default:None
.
- Returns:
out -- The input a in Fortran, or column-major, order.
- Return type:
dpnp.ndarray
Limitations
Parameter like is supported only with default value
None
. Otherwise, the function raisesNotImplementedError
exception.See also
dpnp.ascontiguousarray
Convert input to a contiguous (C order) array.
dpnp.asanyarray
Convert input to an ndarray with either row or column-major memory order.
dpnp.require
Return an ndarray that satisfies requirements.
dpnp.ndarray.flags
Information about the memory layout of the array.
Examples
>>> import dpnp as np
Starting with a C-contiguous array:
>>> x = np.ones((2, 3), order='C') >>> x.flags['C_CONTIGUOUS'] True
Calling
asfortranarray
makes a Fortran-contiguous copy:>>> y = np.asfortranarray(x) >>> y.flags['F_CONTIGUOUS'] True >>> x is y False
Now, starting with a Fortran-contiguous array:
>>> x = np.ones((2, 3), order='F') >>> x.flags['F_CONTIGUOUS'] True
Then, calling
asfortranarray
returns the same object:>>> y = np.asfortranarray(x) >>> x is y True
Creating an array on a different device or with a specified usm_type
>>> x0 = np.asarray([1, 2, 3]) >>> x = np.asfortranarray(x0) # default case >>> x, x.device, x.usm_type (array([1, 2, 3]), Device(level_zero:gpu:0), 'device')
>>> y = np.asfortranarray(x0, device="cpu") >>> y, y.device, y.usm_type (array([1, 2, 3]), Device(opencl:cpu:0), 'device')
>>> z = np.asfortranarray(x0, usm_type="host") >>> z, z.device, z.usm_type (array([1, 2, 3]), Device(level_zero:gpu:0), 'host')