cuda.tile.broadcast_to#

cuda.tile.broadcast_to(x, /, shape)#

Broadcasts a tile to the specified shape following Numpy broadcasting rule.

Parameters:
  • x (Tile) – input tile.

  • shape (tuple[const int,...]) – target shape.

Return type:

Tile

Examples

tx = ct.arange(4, dtype=ct.int32)
ty = ct.broadcast_to(tx, (2, 4))
print(ty)
import cuda.tile as ct
import torch

@ct.kernel
def kernel():
    tx = ct.arange(4, dtype=ct.int32)
    ty = ct.broadcast_to(tx, (2, 4))
    print(ty)


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

Output

[[0, 1, 2, 3], [0, 1, 2, 3]]