numba_dpex.utils.type_conversion_fns module

Provides helper functions to convert from numba types to numba_dpex types.

Currently the module supports the following converter functions:
  • npytypes_array_to_dppy_array: types.npytypes.Array to

    numba_dpex.dppy_array_type.DPPYArray.

numba_dpex.utils.type_conversion_fns.npytypes_array_to_dppy_array(arrtype, addrspace=1)

Convert Numba’s Array type to numba_dpex’s DPPYArray type.

Numba’s Array type does not have a notion of address space for the data pointer. numba_dpex defines its own array type, DPPYArray, that is similar to Numba’s Array, but the data pointer has an associated address space. In addition, the meminfo and the parent attributes of Array are stored as CPointer types instead of PyObject. The converter function converts the Numba Array type to DPPYArray type with address space of pointer members typed to the specified address space.

Args:
arrtype (numba.types): A numba data type that should be

numba.types.Array.

specified: Defaults to numba_dpex.utils.address_space.GLOBAL.

The SPIR-V address space to which the data pointer of the array belongs.

Returns: The numba_dpex data type corresponding to the input numba type.

Raises:
NotImplementedError: If the input numba type is not

numba.types.Array

numba_dpex.utils.type_conversion_fns.suai_to_dppy_array_type(arr, addrspace=1)

Create type for Array with __sycl_usm_array_interface__ (SUAI) attribute.

This function cretes a Numba type for arrays with SUAI attribute.

Args:

arr: Array with SUAI attribute. addrspace: Address space this array is allocated in.

Returns: The Numba type for SUAI array.

Raises:

NotImplementedError: If the dtype of the passed array is not supported.