arrayfire.interop module¶
Interop with other python packages.
This module provides helper functions to copy data to arrayfire from the following modules:
- numpy - numpy.ndarray
- pycuda - pycuda.gpuarray
- pyopencl - pyopencl.array
- numba - numba.cuda.cudadrv.devicearray.DeviceNDArray
-
arrayfire.interop.
from_ndarray
(np_arr, copy=True)¶ Convert numpy.ndarray to arrayfire.Array.
Parameters: np_arr : numpy.ndarray()
copy : Bool specifying if array is to be copied.
Default is true. Can only be False if array is fortran contiguous.
Returns: af_arr : arrayfire.Array()
-
arrayfire.interop.
np_to_af_array
(np_arr, copy=True)[source]¶ Convert numpy.ndarray to arrayfire.Array.
Parameters: np_arr : numpy.ndarray()
copy : Bool specifying if array is to be copied.
Default is true. Can only be False if array is fortran contiguous.
Returns: af_arr : arrayfire.Array()
-
arrayfire.interop.
pycuda_to_af_array
(pycu_arr, copy=True)[source]¶ Convert pycuda.gpuarray to arrayfire.Array
Parameters: pycu_arr : pycuda.GPUArray()
copy : Bool specifying if array is to be copied.
Default is true. Can only be False if array is fortran contiguous.
Returns: af_arr : arrayfire.Array()
-
arrayfire.interop.
to_array
(in_array, copy=True)[source]¶ Helper function to convert input from a different module to af.Array
Parameters: in_array : array like object
Can be one of the following: - numpy.ndarray - pycuda.GPUArray - pyopencl.Array - numba.cuda.cudadrv.devicearray.DeviceNDArray - array.array - list
copy : Bool specifying if array is to be copied.
Default is true. Can only be False if array is fortran contiguous.
Returns: af.Array of same dimensions as input after copying the data from the input