dpctl.tensor

Data Parallel Tensor Collection

dpctl.tensor is an experimental collection of tensor implementations that will implement future Python data API (https://data-apis.github.io/array-api/latest/).

Available tensor implementations:

numpy_usm_shared:

Provides a numpy.ndarray sub-class whose underlying memory buffer is allocated with a USM shared memory allocator.

class dpctl.tensor.usm_ndarray
usm_ndarray(

shape, dtype=”|f8”, strides=None, buffer=’device’, offset=0, order=’C’, buffer_ctor_kwargs=dict()

)

See dpctl.memory.MemoryUSMShared for allowed keyword arguments.

buffer can be ‘shared’, ‘host’, ‘device’ to allocate new device memory by calling respective constructor with the specified buffer_ctor_kwrds; buffer can be an instance of dpctl.memory.MemoryUSMShared, dpctl.memory.MemoryUSMDevice, or dpctl.memory.MemoryUSMHost; buffer can also be another usm_ndarray instance, in which case its underlying MemoryUSM* buffer is used for buffer.

T
base_
device

Returns data-API object representing residence of the array data.

dtype

Returns NumPy’s dtype corresponding to the type of the array elements.

flags

Currently returns integer whose bits correspond to the flags.

flags_
imag
itemsize

Size of array element in bytes.

nbytes

Total bytes consumed by the elements of the array.

nd_
ndim

Gives the number of indices needed to address elements of this array.

real
shape

Elements of the shape tuple give the lengths of the respective array dimensions.

size

Number of elements in the array.

strides

Returns memory displacement in array elements, upon unit change of respective index.

E.g. for strides (s1, s2, s3) and multi-index (i1, i2, i3)

a[i1, i2, i3] == (&a[0,0,0])[ s1*s1 + s2*i2 + s3*i3]

sycl_context

Returns dpctl.SyclContext object to which USM data is bound.

sycl_device

Returns dpctl.SyclDevice object on which USM data was allocated.

sycl_queue

Returns dpctl.SyclQueue object associated with USM data.

to_device()

Transfer array to target device

typenum_
usm_data

Gives USM memory object underlying usm_array instance.

usm_type

USM type of underlying memory. Can be ‘device’, ‘shared’, or ‘host’.

See: https://docs.oneapi.com/versions/latest/dpcpp/iface/usm.html