cuda.tile.printf#

cuda.tile.printf(format, *args)#

Print the values at runtime from the device

Parameters:
  • format (str) – a c-printf style format string in the form of %[flags][width][.precision][length]specifier, where specifier is limited to integer and float for now, i.e. [diuoxXeEfFgGaA]

  • *args (tuple[Tile, ...]) – Only tile input is supported.

Examples

tile = ct.full((), 42, dtype=ct.int32)
ct.printf("value: %d\n", tile)
import cuda.tile as ct
import torch

@ct.kernel
def kernel():
    tile = ct.full((), 42, dtype=ct.int32)
    ct.printf("value: %d\n", tile)


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

Output

value: 42

Notes

This operation has significant overhead, and should only be used for debugging purpose.