numba_dpex package

Subpackages

Submodules

Module contents

The numba-dpex extension module adds data-parallel offload support to Numba.

class numba_dpex.Array(*args, **kwargs)

Bases: Array

An array type for use inside our compiler pipeline.

property box_type

Returns the Python type to box to.

copy(dtype=None, ndim=None, layout=None, readonly=None, addrspace=None)
is_precise()

Whether this type is precise, i.e. can be part of a successful type inference. Default implementation returns True.

property key

A property used for __eq__, __ne__ and __hash__. Can be overridden in subclasses.

class numba_dpex.DpctlSyclQueue(*args, **kwargs)

Bases: Type

A Numba type to represent a dpctl.SyclQueue PyObject.

property box_type
property key

Returns a Python object used as the key to cache an instance of DpctlSyclQueue. The key is constructed by hashing the actual dpctl.SyclQueue object encapsulated by an instance of DpctlSyclQueue. Doing so ensures, that different dpctl.SyclQueue instances are inferred as separate instances of the DpctlSyclQueue type. Returns:

int: hash of the self._sycl_queue Python object.

rand_digit_str(n)
property sycl_device

Returns the SYCL oneAPI extension filter string associated with the queue.

Returns:

str: A SYCL oneAPI extension filter string

class numba_dpex.DpnpNdArray(*args, **kwargs)

Bases: USMNdArray

The Numba type to represent an dpnp.ndarray. The type has the same structure as USMNdArray used to represent dpctl.tensor.usm_ndarray.

property is_internal

Sets the property so that DpnpNdArray expressions can be converted to Numba array_expression objects.

Returns:

bool: Always returns True.

class numba_dpex.NdRange(global_size, local_size)

Bases: object

A class to encapsulate all kernel launch parameters.

The NdRange defines the index space for a work group as well as the global index space. It is passed to parallel_for to execute a kernel on a set of work items.

This class basically contains two Range object, one for the global_range and the other for the local_range. The global_range parameter contains the global index space and the local_range parameter contains the index space of a work group. This class mimics the behavior of sycl::nd_range class.

get_global_range()

Returns a Range defining the index space.

Returns:

Range: A Range object defining the index space.

get_local_range()

Returns a Range defining the index space of a work group.

Returns:

Range: A Range object to specify index space of a work group.

property global_range

Accessor for global_range.

Returns:

Range: The global_range Range object.

property local_range

Accessor for local_range.

Returns:

Range: The local_range Range object.

class numba_dpex.Range(dim0, dim1=None, dim2=None)

Bases: tuple

A data structure to encapsulate a single kernel launch parameter.

The range is an abstraction that describes the number of elements in each dimension of buffers and index spaces. It can contain 1, 2, or 3 numbers, depending on the dimensionality of the object it describes.

This is just a wrapper class on top of a 3-tuple. The kernel launch parameter is consisted of three int’s. This class basically mimics the behavior of sycl::range.

get(index)

Returns the range of a single dimension.

Args:

index (int): The index of the dimension, i.e. [0,2]

Returns:

int: The range of the dimension indexed by index.

size()

Returns the size of a range.

Returns the size of a range by multiplying the range of the individual dimensions.

Returns:

int: The size of a range.

class numba_dpex.USMNdArray(*args, **kwargs)

Bases: Array

A type class to represent dpctl.tensor.usm_ndarray.

property as_array

The equivalent array type, for operations supporting array-compatible objects (such as ufuncs).

property box_type

Returns the Python type to box to.

can_convert_to(typingctx, other)

Convert this USMNdArray to the other.

copy(dtype=None, ndim=None, layout=None, readonly=None, addrspace=None, device=None, usm_type=None)
property key

A property used for __eq__, __ne__ and __hash__. Can be overridden in subclasses.

unify(typingctx, other)

Unify this with the other USMNdArray.

numba_dpex.usm_ndarray

alias of USMNdArray