Skip to content

utils

Memory Planners Utilities API

The utils module provides utility functions for memory planning in the AOT compilation process.

Functions:

Copyright 2025 Ambiq. All Rights Reserved.

Classes

Functions

compute_tensor_lifetimes

compute_tensor_lifetimes(model: AirModel) -> dict[TensorId, TensorLifetime]

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:

  • model

    (AirModel) –

    The model to compute tensor lifetimes for.

Returns:

  • lifetimes ( dict[TensorId, TensorLifetime] ) –

    Mapping from tensor ID to its lifetime.

merge_free_list

merge_free_list(free_list: list[MemoryFreeBlock]) -> list[MemoryFreeBlock]

Merge contiguous free blocks.

Parameters:

Returns: