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:
- 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.