Skip to content

constants

torch_to_nnef.nemo_tract.constants

Constants and small helpers for NeMo Tract wrappers.

This module centralizes shared string constants and tiny predicates used across wrappers to keep the main logic files focused.

axis_kind_to_symbol

axis_kind_to_symbol(ax: Any) -> str

Return a normalized symbol for an axis kind using full names.

Newer Tract versions accept multi-letter symbols, so prefer clear names (e.g., BATCH, TIME, STREAM) instead of single letters.

make_axis_symbol

make_axis_symbol(input_name: str, axis_kind: Any, axis_index: int) -> str

Produce a readable, namespaced axis symbol.

  • Batch axis: namespaced as INPUT{SEP}BATCH (per-input), not a global BATCH; where SEP is NEMO_INPUT_SYMBOL_SEPARATOR.
  • Known kinds (e.g., TIME, STREAM, LENGTH): use full kind name and namespace by input (e.g., AUDIO_SIGNAL{SEP}TIME) to avoid accidental cross-input collisions.
  • Unknown kinds: fall back to a generic numbered dim also namespaced by input (e.g., AUDIO_SIGNAL__DIM0).