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 (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.SyclDevicecorresponding to a non-partitioned SYCL device, an instance ofdpctl.SyclQueue, or a Device object returned bydpnp.dpnp_array.dpnp_array.deviceproperty.usm_type ({None, "device", "shared", "host"}, optional) – The type of SYCL USM allocation for the output array. Default is
None.sycl_queue ({None, SyclQueue}, optional) – A SYCL queue to use for output array allocation and copying.
- 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 raises NotImplementedError exception.See also
dpnp.ascontiguousarrayConvert input to a contiguous (C order) array.
dpnp.asanyarrayConvert input to an ndarray with either row or column-major memory order.
dpnp.requireReturn an ndarray that satisfies requirements.
dpnp.ndarray.flagsInformation 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
asfortranarraymakes 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
asfortranarrayreturns 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')