helion.language.full#
- helion.language.full(shape, value, dtype=torch.float32, device=None)[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, usetorch.full()with proper device placement.- Parameters:
shape (
Sequence[object]) – A list of sizes (or tile indices which are implicitly converted to sizes)value (
float|Tensor) – The number or zero-dimensional tensor to fill the tensor withdtype (
dtype) – The data type of the tensor (default: torch.float32)device (
device|None) – Device must match the current compile environment device
- Returns:
A device tensor of the given shape and dtype filled with value
- Return type:
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