cuda.tile.unpack_from_bytes#

cuda.tile.unpack_from_bytes(x, /, dtype)#

Reinterprets a 1D uint8 byte tile as a 1D tile of the target data type.

The inverse of pack_to_bytes(). The input must be a 1D tile of dtype uint8, and the total number of bits must be divisible by the target data type bit width.

Parameters:
  • x (Tile) – a 1D tile of dtype uint8.

  • dtype (DType) – target data type.

Returns:

a 1D tile of dtype with num_bytes * 8 // bit width elements.

Return type:

Tile

Examples

tx = ct.arange(4, dtype=ct.uint8) + 1
ty = ct.unpack_from_bytes(tx, ct.int32)
print(f"{ty:#x}")
import cuda.tile as ct
import torch

@ct.kernel
def kernel():
    tx = ct.arange(4, dtype=ct.uint8) + 1
    ty = ct.unpack_from_bytes(tx, ct.int32)
    print(f"{ty:#x}")


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

Output

[0x4030201]