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_arrnumpy.ndarray()
- copyBool specifying if array is to be copied.
Default is true. Can only be False if array is fortran contiguous.
- Returns
- af_arrarrayfire.Array()
-
arrayfire.interop.
np_to_af_array
(np_arr, copy=True)[source]¶ Convert numpy.ndarray to arrayfire.Array.
- Parameters
- np_arrnumpy.ndarray()
- copyBool specifying if array is to be copied.
Default is true. Can only be False if array is fortran contiguous.
- Returns
- af_arrarrayfire.Array()
-
arrayfire.interop.
to_array
(in_array, copy=True)[source]¶ Helper function to convert input from a different module to af.Array
- Parameters
- in_arrayarray like object
Can be one of the following: - numpy.ndarray - pycuda.GPUArray - pyopencl.Array - numba.cuda.cudadrv.devicearray.DeviceNDArray - array.array - list
- copyBool 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