helion.language.full

helion.language.full(shape, value, dtype=torch.float32)[source]

Create a device-tensor filled with a specified value.

Note

Only use within hl.tile() loops for creating local tensors. For output tensor creation, use torch.full() with proper device placement.

Parameters:
  • shape (list[object]) – A list of sizes (or tile indices which are implicitly converted to sizes)

  • value (float) – The value to fill the tensor with

  • dtype (dtype) – The data type of the tensor (default: torch.float32)

Returns:

A device tensor of the given shape and dtype filled with value

Return type:

torch.Tensor

Examples

@helion.kernel
def process_kernel(input: torch.Tensor) -> torch.Tensor:
    result = torch.empty_like(input)

    for tile in hl.tile(input.size(0)):
        # Create local buffer filled with initial value
        buffer = hl.full([tile], 0.0, dtype=input.dtype)
        buffer += input[tile]  # Add input values to buffer
        result[tile] = buffer

    return result

See also