cuda.tile.num_tiles#

cuda.tile.num_tiles(array, /, axis, shape, order='C')#

Gets the number of tiles in the tile space of the array along the axis.

Parameters:
  • array (Array) – An array object on a cuda device.

  • axis (const int) – The axis of the tile partition space to get the dim size.

  • shape (const int...) – A sequence of const integers definining the shape of the tile.

  • order ("C" or "F", or tuple[const int,...]) – Order of axis mapping. See load().

Returns:

int32

Return type:

int

Examples

@ct.kernel
def kernel(x):
    tile_shape = (4, 8)
    num_tiles_row = ct.num_tiles(x, 0, shape=tile_shape)
    num_tiles_col = ct.num_tiles(x, 1, shape=tile_shape)
    print(f"The tile space has {num_tiles_row} rows and {num_tiles_col} columns.")

x = torch.empty(42, 64, 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):
    tile_shape = (4, 8)
    num_tiles_row = ct.num_tiles(x, 0, shape=tile_shape)
    num_tiles_col = ct.num_tiles(x, 1, shape=tile_shape)
    print(f"The tile space has {num_tiles_row} rows and {num_tiles_col} columns.")

x = torch.empty(42, 64, device='cuda')
ct.launch(stream, (1,), kernel, (x,))

torch.cuda.synchronize()

Output

The tile space has 11 rows and 8 columns.