emmi_inference.common

Classes

SaveFormat

Supported on-disk formats for tensor outputs.

DictMode

How to persist mapping outputs.

Functions

sanitize_suffix(suffix)

Sanitize a suffix for safe filesystem usage.

Module Contents

class emmi_inference.common.SaveFormat

Bases: str, enum.Enum

Supported on-disk formats for tensor outputs.

Values:

PYTORCH_PT: PyTorch serialized tensor/map (.pt). PYTORCH_TH: Alias, normalized to .pt. PYTORCH_PTH: Alias, normalized to .pt. NUMPY_NPY: NumPy array (.npy) for single tensors. NUMPY_NPZ: Compressed NumPy archive (.npz) for mappings.

Initialize self. See help(type(self)) for accurate signature.

PYTORCH_PT = 'pt'
PYTORCH_TH = 'th'
PYTORCH_PTH = 'pth'
NUMPY_NPY = 'npy'
NUMPY_NPZ = 'npz'
classmethod normalize(save_format)

Return the canonical save format.

Parameters:

save_format (SaveFormat) – A concrete SaveFormat.

Returns:

PYTORCH_PT when given PYTORCH_TH/PYTORCH_PTH, otherwise the input value.

Return type:

SaveFormat

class emmi_inference.common.DictMode

Bases: str, enum.Enum

How to persist mapping outputs.

Values:

SPLIT: Write one file per key (suffix _key appended to the stem). SINGLE: Write a single container file containing all key/value pairs.

Initialize self. See help(type(self)) for accurate signature.

SPLIT = 'split'
SINGLE = 'single'
emmi_inference.common.sanitize_suffix(suffix)

Sanitize a suffix for safe filesystem usage.

Replaces characters outside [A-Za-z0-9_-] with _.

Parameters:

suffix (str) – Raw suffix text (e.g., a dictionary key).

Returns:

A filesystem-friendly suffix.

Return type:

str