utils
Memory Planners Utilities API
The utils module provides utility functions for memory planning in the AOT compilation process.
Functions:
-
compute_tensor_lifetimes–Computes the lifetimes of tensors based on the operators.
-
merge_free_list–Merges contiguous free blocks in memory.
Copyright 2025 Ambiq. All Rights Reserved.
Classes
Functions
compute_tensor_lifetimes
Compute the lifetimes of tensors based on the operators.
For each tensor, compute its lifetime as a tuple (first, last) based on the operator order. The lifetime is defined by the first operator that uses or produces the tensor and the last operator that uses it.
Parameters:
-
(modelAirModel) –The model to compute tensor lifetimes for.
Returns:
-
lifetimes(dict[TensorId, TensorLifetime]) –Mapping from tensor ID to its lifetime.
merge_free_list
Merge contiguous free blocks.
Parameters:
-
(free_listlist[MemoryFreeBlock]) –List of MemoryFreeBlock instances.
Returns:
-
merged(list[MemoryFreeBlock]) –A new list with contiguous blocks merged.