cuda.tile.Tile#

class cuda.tile.Tile#

Class for tile objects.

property dtype: DType#

The data type of the tile’s elements.

Return type:

DType (constant)

property shape: tuple[int, ...]#

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

Return type:

tuple[const int,…]

property ndim: int#

The number of dimensions in the tile.

Return type:

int (constant)

item()#

Equivalent to self.reshape(()).

Returns:

A scalar tile.

Return type:

Tile

Examples

@ct.kernel
def kernel(x):
    idx = ct.full((1,), 2, dtype=ct.int32).item()
    tile = ct.load(x, (idx,), shape=(4,))
    print(tile)

x = torch.arange(16, device='cuda')
ct.launch(stream, (1,), kernel, (x,))
import cuda.tile as ct
import torch

torch.cuda.init()
stream = torch.cuda.current_stream()

@ct.kernel
def kernel(x):
    idx = ct.full((1,), 2, dtype=ct.int32).item()
    tile = ct.load(x, (idx,), shape=(4,))
    print(tile)

x = torch.arange(16, device='cuda')
ct.launch(stream, (1,), kernel, (x,))

torch.cuda.synchronize()

Output

[8, 9, 10, 11]
extract(index, shape)#

See extract().

reshape(shape)#

See reshape().

permute(axes)#

See permute().

transpose(axis0=None, axis1=None)#

See transpose().

astype(dtype)#

See astype().

__index__()#

0D Tile can be used as index in range

__getitem__(index)#

Syntax sugar for expand_dim

__add__(other)#
__sub__(other)#
__mul__(other)#
__truediv__(other)#
__floordiv__(other)#
__mod__(other)#
__pow__(other)#
__and__(other)#
__or__(other)#

Return self|value.

__xor__(other)#
__radd__(other)#
__rsub__(other)#
__rmul__(other)#
__rtruediv__(other)#
__rfloordiv__(other)#
__rmod__(other)#
__rpow__(other)#
__rand__(other)#
__ror__(other)#

Return value|self.

__rxor__(other)#
__ge__(other)#

Return self>=value.

__gt__(other)#

Return self>value.

__le__(other)#

Return self<=value.

__lt__(other)#

Return self<value.

__eq__(other)#

Return self==value.

__ne__(other)#

Return self!=value.

__neg__()#
__invert__()#
__matmul__(other)#
__rmatmul__(other)#
__hash__ = None#