Skip to content

utils

AOT Handler Utilities API

The utils module provides utility functions for AOT handlers.

Copyright 2025 Ambiq. All Rights Reserved.

Classes

Functions

generate_mermaid

generate_mermaid(model: AirModel, direction: str = 'TB') -> str

Generate a Mermaid flowchart showing operator connectivity.

Parameters:

  • model

    (AirModel) –

    The model to generate the flowchart for.

  • direction

    (str, default: 'TB' ) –

    Mermaid graph direction (“TB”, “LR”, etc.)

Returns:

  • str ( str ) –

    Mermaid code as a string.

sanitize_for_c_comment

sanitize_for_c_comment(text: str | bytes | bytearray) -> str

Sanitize a string (or bytes) so it can safely live inside a C block comment (/ ... /).

Transforms: - If bytes/bytearray, decode as UTF-8 (replacing errors). - Replaces '/' with '/ ' and '/' with ' /' - Strips out non-printable/control chars except tab/newline/carriage-return.

Parameters:

Returns:

  • str ( str ) –

    Sanitized text.

generate_stimulus_data

generate_stimulus_data(tensor: AirTensor) -> np.ndarray

Generate random stimulus data for given tensor

Parameters:

Returns:

  • ndarray

    np.ndarray: Generated stimulus data