cuda.tile.astile#

cuda.tile.astile(value, /, *, dtype)#

Creates a tile from a value.

Parameters:
  • value (scalar | (nested) tuple of scalar) – A scalar (yielding a 0-d tile), or a (possibly nested) tuple of scalars whose nesting determines the tile’s shape. Every tuple’s length must be a power of two, and sibling tuples at each level must have uniform length.

  • dtype (DType) – The Data type of the tile.

Returns:

A tile shaped from value, with elements cast to dtype.

Return type:

Tile

Examples

x = ct.astile(((1, 2), (3, 4)), dtype=ct.int32)
print(x)
import cuda.tile as ct
import torch

@ct.kernel
def kernel():
    x = ct.astile(((1, 2), (3, 4)), dtype=ct.int32)
    print(x)


torch.cuda.init()
ct.launch(torch.cuda.current_stream(), (1,), kernel, ())
torch.cuda.synchronize()

Output

[[1, 2], [3, 4]]