cuda.tile.transpose#

cuda.tile.transpose(x, /, axis0=None, axis1=None)#

Transposes two axes of the input tile with at least 2 dimensions.

For a 2-dimensional tile, the two axes are transposed if axis0 and axis1 are not specified. For tiles with more than 2 dimensions, axis0 and axis1 must be explicitly specified.

Parameters:
  • x (Tile) – input tile.

  • axis0 (const int) – the first axis to transpose.

  • axis1 (const int) – the second axis to transpose.

Return type:

Tile

Examples

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

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


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

Output

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