tilus.Script.global_tensor¶
- Script.global_tensor(dtype, shape, *, layout=None, requires_clean)[source]¶
Allocate a global tensor.
This instruction allocates a global tensor with the specified data type, shape, layout, and whether it requires to be all zeros. All thread blocks in the kernel must agree on the shape and layout of the global tensor. The global tensor will be shared across all thread blocks in the kernel. The lifetime of the global tensor is the entire kernel execution, and it will be automatically freed when the kernel finishes.
The requires_clean parameter indicates whether the global tensor should be initialized to all zeros.
If it is set to True, the global tensor will be initialized to all zeros. We require the kernel to reset the global tensor to all zeros after the kernel finishes.
If it is set to False, the global tensor will be uninitialized, and its contents are undefined.
- Parameters:
dtype (DataType) – The data type of the tensor elements.
shape (Sequence[int | Expr]) – The shape of the tensor. The shape can be a sequence of integers or integer expressions.
layout (GlobalLayout, optional) – The layout of the tensor. If not provided, the layout will be row-major compact layout by default.
requires_clean (bool) – Whether the global tensor should be initialized to all zeros.
- Returns:
ret – The allocated global tensor.
- Return type: