# helia_edge.export.spec

Typed export specification; importable without Keras or a training backend.

## helia_edge.export.spec.VALID_IO

`constant` · `python`

```python
VALID_IO: dict[Precision, frozenset[IODType]] = {Precision.FP32: frozenset({IODType.FLOAT32}), Precision.FP16: frozenset({IODType.FLOAT16}), Precision.A8W8: frozenset({IODType.INT8, IODType.FLOAT32}), Precision.A16W8: frozenset({IODType.INT16, IODType.FLOAT32})}
```

Source: `helia_edge/export/spec.py:71`

## helia_edge.export.spec.CALIBRATED

`constant` · `python`

```python
CALIBRATED: frozenset[Precision] = frozenset({Precision.A8W8, Precision.A16W8})
```

Source: `helia_edge/export/spec.py:78`

## helia_edge.export.spec.Precision

`class` · `python`

```python
Precision()
```

Numeric format of an exported graph.

Source: `helia_edge/export/spec.py:11`

### helia_edge.export.spec.Precision.FP32

`constant` · `python`

```python
FP32 = 'fp32'
```

float32 weights and compute.

Source: `helia_edge/export/spec.py:21`

### helia_edge.export.spec.Precision.FP16

`constant` · `python`

```python
FP16 = 'fp16'
```

native float16 graph; inputs, weights, activations and outputs are float16.

Source: `helia_edge/export/spec.py:22`

### helia_edge.export.spec.Precision.A8W8

`constant` · `python`

```python
A8W8 = 'a8w8'
```

int8 activations and weights, calibrated.

Source: `helia_edge/export/spec.py:23`

### helia_edge.export.spec.Precision.A16W8

`constant` · `python`

```python
A16W8 = 'a16w8'
```

int16 activations and int8 weights, calibrated.

Source: `helia_edge/export/spec.py:24`

## helia_edge.export.spec.IODType

`class` · `python`

```python
IODType()
```

Element type of an exported model's inputs and outputs.

Source: `helia_edge/export/spec.py:27`

### helia_edge.export.spec.IODType.FLOAT32

`constant` · `python`

```python
FLOAT32 = 'float32'
```

Source: `helia_edge/export/spec.py:30`

### helia_edge.export.spec.IODType.FLOAT16

`constant` · `python`

```python
FLOAT16 = 'float16'
```

Source: `helia_edge/export/spec.py:31`

### helia_edge.export.spec.IODType.INT8

`constant` · `python`

```python
INT8 = 'int8'
```

Source: `helia_edge/export/spec.py:32`

### helia_edge.export.spec.IODType.INT16

`constant` · `python`

```python
INT16 = 'int16'
```

Source: `helia_edge/export/spec.py:33`

## helia_edge.export.spec.ConversionMode

`class` · `python`

```python
ConversionMode()
```

How the Keras model is traced for conversion.

Source: `helia_edge/export/spec.py:36`

### helia_edge.export.spec.ConversionMode.KERAS

`constant` · `python`

```python
KERAS = 'keras'
```

Source: `helia_edge/export/spec.py:39`

### helia_edge.export.spec.ConversionMode.SAVED_MODEL

`constant` · `python`

```python
SAVED_MODEL = 'saved_model'
```

Source: `helia_edge/export/spec.py:40`

### helia_edge.export.spec.ConversionMode.CONCRETE

`constant` · `python`

```python
CONCRETE = 'concrete'
```

Source: `helia_edge/export/spec.py:41`

## helia_edge.export.spec.TensorRole

`class` · `python`

```python
TensorRole()
```

Role of a model input or output.

Source: `helia_edge/export/spec.py:44`

### helia_edge.export.spec.TensorRole.SIGNAL

`constant` · `python`

```python
SIGNAL = 'signal'
```

Source: `helia_edge/export/spec.py:47`

### helia_edge.export.spec.TensorRole.STATE

`constant` · `python`

```python
STATE = 'state'
```

Source: `helia_edge/export/spec.py:48`

### helia_edge.export.spec.TensorRole.AUX

`constant` · `python`

```python
AUX = 'aux'
```

Source: `helia_edge/export/spec.py:49`

## helia_edge.export.spec.state_input_name

`function` · `python`

```python
state_input_name(k: int) -> str
```

Name of the input of state pair ``k``.

Source: `helia_edge/export/spec.py:55`

## helia_edge.export.spec.state_output_name

`function` · `python`

```python
state_output_name(k: int) -> str
```

Name of the output of state pair ``k``.

Source: `helia_edge/export/spec.py:60`

## helia_edge.export.spec.state_pair

`function` · `python`

```python
state_pair(name: str) -> tuple[str, int] | None
```

``("in", k)`` or ``("out", k)`` for a state tensor name, otherwise None.

Source: `helia_edge/export/spec.py:65`

## helia_edge.export.spec.ExportSpec

`class` · `python`

```python
ExportSpec()
```

What to export. ``precision``, ``io_dtype`` and ``mode`` have no defaults.

Source: `helia_edge/export/spec.py:81`

### helia_edge.export.spec.ExportSpec.model_config

`attribute` · `python`

```python
model_config = ConfigDict(frozen=True, extra='forbid')
```

Source: `helia_edge/export/spec.py:97`

### helia_edge.export.spec.ExportSpec.format

`attribute` · `python`

```python
format: Literal['litert'] = 'litert'
```

Export format: ``litert``, a ``.tflite`` flatbuffer (the only one).

Source: `helia_edge/export/spec.py:99`

### helia_edge.export.spec.ExportSpec.precision

`attribute` · `python`

```python
precision: Precision
```

Numeric format of the graph.

Source: `helia_edge/export/spec.py:100`

### helia_edge.export.spec.ExportSpec.io_dtype

`attribute` · `python`

```python
io_dtype: IODType
```

Input and output element type; must be valid for ``precision`` (``VALID_IO``).

Source: `helia_edge/export/spec.py:101`

### helia_edge.export.spec.ExportSpec.mode

`attribute` · `python`

```python
mode: ConversionMode
```

How the model is traced for conversion.

Source: `helia_edge/export/spec.py:102`

### helia_edge.export.spec.ExportSpec.strict

`attribute` · `python`

```python
strict: StrictBool = True
```

For calibrated precisions, refuse operators without an integer kernel instead of
falling back to float operators. Defaults to True; it does not affect float precisions.

Source: `helia_edge/export/spec.py:103`

### helia_edge.export.spec.ExportSpec.state_tie_tolerance

`attribute` · `python`

```python
state_tie_tolerance: StrictFloat = Field(default=0.01, ge=0.0, le=0.5)
```

For calibrated precisions with integer I/O, export gives each state pair
(``state_in_k``, ``state_out_k``) one scale and zero point covering both tensors' ranges, and
refuses when that scale differs from either original by more than this fraction of it (at
most 0.5). Models without state pairs ignore it.

Source: `helia_edge/export/spec.py:104`

## helia_edge.export.spec.BackendUnavailable

`class` · `python`

```python
BackendUnavailable()
```

The active Keras backend cannot export: LiteRT export needs the TensorFlow backend.

Source: `helia_edge/export/spec.py:117`

## helia_edge.export.spec.check_resets

`function` · `python`

```python
check_resets(resets: Collection[int], steps: int, stateful: bool, what: str) -> None
```

Refuse state resets that are not increasing steps from 1 to ``steps - 1`` of a streaming model.

**Raises**

| Name | Description |
| --- | --- |
| ValueError | If ``resets`` are given for a model without state, or are not increasing steps within the sequence (step 0 always starts from zero states). |

Source: `helia_edge/export/spec.py:121`
