triton.language.to_tensor

triton.language.to_tensor(x, _semantic=None)

Converts a Python scalar into a 0-dimensional tensor.

If x is already a tensor it is returned unchanged. The result dtype is inferred from the value: a Python bool becomes tl.int1, an int becomes the smallest of tl.int32, tl.uint32, tl.int64, or tl.uint64 that can represent it, and a float becomes tl.float32 (or tl.float64 when it is outside the float32 range).

Parameters:

x – any numeric value.