Mojo function
stack_allocation
stack_allocation[LayoutType: TensorLayout, //, dtype: DType, address_space: AddressSpace = AddressSpace.GENERIC](var layout: LayoutType) -> TileTensor[dtype, LayoutType, MutExternalOrigin, address_space=address_space] where LayoutType.all_dims_known
Allocate a TileTensor on the stack with the given layout.
Creates a stack-allocated buffer sized for the layout and returns a TileTensor pointing to it. The layout must have all dimensions known at compile time.
Constraints:
All layout dimensions must be statically known.
Parameters:
- βLayoutType (
TensorLayout): The layout type (inferred from layout argument). - βdtype (
DType): The data type of tensor elements. - βaddress_space (
AddressSpace): Memory address space (default: GENERIC).
Args:
- βlayout (
LayoutType): The layout instance defining shape and strides.
Returns:
TileTensor: A mutable TileTensor backed by stack-allocated memory.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!