# exporter

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

Export of models to the RVC2 platform.

The conversion runs inside the RVC2 Docker image and has two stages: OpenVINO's model optimizer (`mo`) turns the ONNX model into
an OpenVINO IR, and `compile_tool` compiles that IR into a `.blob` for a fixed number of SHAVE cores. Optionally, a blob is
compiled for every SHAVE count and the results are packed into a single `.superblob`.

## Classes

### CompileResult

Outcome of a single `compile_tool` invocation.

#### Attributes

##### blob_path

Path the compiled blob was written to.

##### result

The finished `compile_tool` subprocess, carrying its peak memory usage.

### RVC2Exporter

Exporter producing an RVC2 blob from an ONNX, TFLite or IR model.

The model is first converted to an OpenVINO IR with `mo` (unless an IR is given as the input) and then compiled with
`compile_tool` for the configured number of SHAVE cores. With the superblob option enabled, a blob is compiled for every SHAVE
count from 1 to 16 and the results are packed into one `.superblob`.

#### Methods

##### init

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

Initialize the exporter from the RVC2 configuration.

Parameters

 * `config` (`SingleStageConfig`): Configuration of the stage to export. Its `rvc2` section supplies the RVC2-specific options.
 * `output_dir` (`Path`): Directory the compiled model and the build information are written to.

##### export

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

Convert the model and compile it for RVC2.

A TFLite input is first converted to ONNX, an ONNX input is converted to an OpenVINO IR and an IR input is used as it is.

Returns

 * `Path`: Path to the compiled `.blob`, or to the `.superblob` if superblob compilation is enabled.

Raises

 * `NotImplementedError`: If the input file type is neither TFLite, ONNX nor OpenVINO IR.

##### exporter_buildinfo

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

Return the RVC2-specific build information.

Returns

 * `Params`: The `mo` and `compile_tool` versions, the target device and the SHAVE and CMX slice counts the model was compiled
   with.

## Attributes

### DEFAULT_SUPER_SHAVES

### OV_2021
