cuda.tile.reshape#

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

Reshapes a tile to the specified shape.

One of the shape elements may be specified as -1 to indicate that the corresponding dimension is to be inferred automatically.

For example, reshaping a (16, 2) tile to (8, -1) will produce a tile of shape (8, 4): as there are 32 elements in total, the second dimension will be computed as 32 divided by 8.

Parameters:
  • x (Tile) – input tile.

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

Return type:

Tile

Examples

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

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


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

Output

[[0, 1, 2, 3], [4, 5, 6, 7]]