cuda.tile.Array#

class cuda.tile.Array#

A global array (or array) is a container of objects stored in a logical multidimensional space.

Global arrays are always stored in memory. Copying an array does not copy the underlying data.

Global arrays can be used in host code and tile code. They can be kernel parameters.

Any object that implements the DLPack format or the CUDA Array Interface can be used as a global array. Example: CuPy arrays and PyTorch tensors.

property dtype#

The data type of the array’s elements.

Return type:

DType (constant)

property shape#

The number of elements in each of the array’s dimensions.

Return type:

tuple[int32,…]

property strides#

The number of elements to step in each dimension while traversing the array.

Return type:

tuple[int32,…]

property ndim#

The number of dimensions in the array.

Return type:

int (constant)

slice(axis, start, stop)#

Creates a view of the array sliced along a single axis.

The returned array references the same underlying memory as array, but with a restricted range from index start (inclusive) to stop (exclusive) along the specified axis. No data is copied.

axis must be a constant integer. Negative values are supported and count from the last dimension (e.g., axis=-1 refers to the last axis).

start and stop must be integers (scalars or 0D tiles). They must satisfy 0 <= start < N and start <= stop <= N, where N is the size of array along the sliced axis.

For example, consider a 2-dimensional array A of shape (M, N). Slicing along axis 0 from start to stop:

>>> sub = A.slice(axis=0, start=start, stop=stop)

The result sub will be an array of shape (stop - start, N). Using NumPy slice notation for illustration, this is equivalent to:

sub = A[start:stop, :]  # NumPy notation for reference only

The slice bounds can be dynamic (runtime values):

>>> # Process variable-length segments
>>> segment = A.slice(axis=1, start=offset, stop=offset + length)
>>> tile = ct.load(segment, (0, 0), shape=(TILE_M, TILE_N))