# helia_edge.importers.readers

Read named tensors from source files: ``path -> {name: array}``, one reader per ``SourceFormat``.

The ``onnx`` reader needs the ``onnx`` extra and the ``torch`` reader the ``torch`` extra; both are
imported only when called. The ``safetensors`` reader uses NumPy alone.

## helia_edge.importers.readers.read_onnx

`function` · `python`

```python
read_onnx(path: Path) -> dict[str, npt.NDArray]
```

The initializers of a self-contained ``.onnx`` model, by name.

Weights held in ``Constant`` nodes rather than initializers are not read; such a source tensor is
reported as not in the file.

**Raises**

| Name | Description |
| --- | --- |
| ValueError | If an initializer is stored in a separate data file, which the source's sha256 does not cover. |

Source: `helia_edge/importers/readers.py:29`

## helia_edge.importers.readers.read_safetensors

`function` · `python`

```python
read_safetensors(path: Path) -> dict[str, npt.NDArray]
```

The tensors of a ``.safetensors`` file, by name (little-endian; BF16 is not supported).

Source: `helia_edge/importers/readers.py:54`

## helia_edge.importers.readers.read_torch

`function` · `python`

```python
read_torch(path: Path) -> dict[str, npt.NDArray]
```

The tensors of a PyTorch state dict saved with ``torch.save``, loaded with ``weights_only=True``.

Source: `helia_edge/importers/readers.py:71`

## helia_edge.importers.readers.read

`function` · `python`

```python
read(format: SourceFormat, path: Path) -> dict[str, npt.NDArray]
```

The tensors of the file at ``path``, read as ``format``.

Source: `helia_edge/importers/readers.py:89`
