Skip to content

activation_runtime

Shared activation runtime helpers.

This module centralizes small activation kernels that would otherwise be re-emitted once per node. Two activation families currently use it:

  • Quantized LUT activations (LOGISTIC, TANH, HARD_SWISH in their int8 form), all of which reduce to the same elementwise gather::

        output[i] = lut[input[i] + offset]
    
  • Int16 LOGISTIC / TANH wrappers, which are thin boilerplate around arm_logistic_s16 / arm_tanh_s16 with per-node size and quant params.

The helpers here collapse those repeated bodies into a single shared runtime function per distinct kernel, so per-node code shrinks to a thin call wrapper while the hot loop or CMSIS call site is compiled exactly once.

Functions

activation_lut_helper

activation_lut_helper(dtype: dtype) -> dict[str, object] | None

Return the shared LUT-helper descriptor for dtype.

Parameters:

  • dtype

    (dtype) –

    The numpy dtype of the activation's input/output/LUT elements.

Returns:

  • dict[str, object] | None

    A descriptor dict with key, ctype and offset entries, or

  • dict[str, object] | None

    None if dtype has no shared LUT helper.

activation_s16_helper

activation_s16_helper(op_name: str) -> dict[str, object] | None

Return the shared int16 helper descriptor for op_name.

Parameters:

  • op_name

    (str) –

    Activation family name (currently logistic or tanh).

Returns:

  • dict[str, object] | None

    A descriptor dict for the shared int16 helper, or None if the

  • dict[str, object] | None

    activation does not currently use a shared int16 helper.

collect_activation_helpers

collect_activation_helpers(operators: list) -> list[dict[str, object]]

Collect the distinct shared activation helpers required by operators.

Parameters:

  • operators

    (list) –

    The resolved :class:AotOperator instances for the model.

Returns:

  • list[dict[str, object]]

    Descriptor dicts (one per distinct helper key) sorted by key, suitable

  • list[dict[str, object]]

    for rendering the shared activations runtime file. Empty when no

  • list[dict[str, object]]

    operator uses a shared activation helper.