# exporter

Python API: `modelconverter.platforms.rvc4.exporter`

Export of models to the RVC4 platform.

Drives the Qualcomm SNPE toolchain shipped in the RVC4 Docker image: `snpe-onnx-to-dlc` (or `snpe-tflite-to-dlc`) produces a DLC
model, `snpe-dlc-quant` quantizes it against the calibration data, and `snpe-dlc-graph-prepare` builds the offline graph for the
targeted HTP SoCs. Which SNPE arguments are used follows from the configured quantization mode unless that mode is `CUSTOM`.

## Classes

### RVC4Exporter

Exporter producing a DLC model for the RVC4 platform.

#### Methods

##### init

```python
def __init__(config: SingleStageConfig, output_dir: Path):
```

Initialize the exporter and pre-process the input model.

The SNPE arguments and the quantization options are taken from the `rvc4` section of the config. Unless the quantization mode is
`CUSTOM`, the user-provided SNPE arguments are dropped in favor of the ones the mode implies. An ONNX input model gets the
configured normalization attached to its inputs and, unless all ONNX optimizations are disabled, is rewritten by
[ONNXModifier](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/utils/onnx_tools.md)
-- the rewritten model is only kept when its outputs still match those of the original.

Parameters

 * `config` (`SingleStageConfig`): Configuration of the stage to export.
 * `output_dir` (`Path`): Directory the exported model is written to.

##### export

```python
def export(self) -> Path:
```

Convert, quantize and graph-prepare the model.

The input model is converted to DLC, quantized unless calibration is disabled, and prepared for the configured HTP SoCs at the
configured optimization level. An `info.csv` dump of the resulting model is written next to it.

Returns

 * `Path`: Path to the exported DLC model.

##### exporter_buildinfo

```python
def exporter_buildinfo(self) -> Params:
```

Collect the RVC4-specific build information.

Returns

 * `Params`: Dictionary with the version of the SNPE tooling the model was exported with and the HTP SoCs it was prepared for.
