# 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

| Name | Description |
| --- | --- |
| [`CompileResult`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/rvc2/exporter.md#exporter-Classes-CompileResult) | Outcome of a single `compile_tool` invocation. |
| [`RVC2Exporter`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/rvc2/exporter.md#exporter-Classes-RVC2Exporter) | Exporter producing an RVC2 blob from an ONNX, TFLite or IR model. |

### class `CompileResult`

```python
class CompileResult(NamedTuple)
```

Outcome of a single `compile_tool` invocation.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `blob_path` | `Path` | Path the compiled blob was written to. |
| `result` | `SubprocessResult` | The finished `compile_tool` subprocess, carrying its peak memory usage. |

### class `RVC2Exporter`

```python
class RVC2Exporter(Exporter)
```

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

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/rvc2/exporter.md#exporter-Classes-RVC2Exporter-__init__) | Initialize the exporter from the RVC2 configuration. |
| [`export`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/rvc2/exporter.md#exporter-Classes-RVC2Exporter-export) | Convert the model and compile it for RVC2. |
| [`exporter_buildinfo`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/rvc2/exporter.md#exporter-Classes-RVC2Exporter-exporter_buildinfo) | Return the RVC2-specific build information. |

#### method `__init__`

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

Initialize the exporter from the RVC2 configuration.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `config` | `SingleStageConfig` | Configuration of the stage to export. Its `rvc2` section supplies the RVC2-specific options. | required |
| `output_dir` | `Path` | Directory the compiled model and the build information are written to. | required |

#### method `export`

```python
def export() -> 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

| Type | Description |
| --- | --- |
| `Path` | Path to the compiled `.blob`, or to the `.superblob` if superblob compilation is enabled. |

Raises

| Type | Description |
| --- | --- |
| `NotImplementedError` | If the input file type is neither TFLite, ONNX nor OpenVINO IR. |

#### method `exporter_buildinfo`

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

Return the RVC2-specific build information.

Returns

| Type | Description |
| --- | --- |
| `Params` | The `mo` and `compile_tool` versions, the target device and the SHAVE and CMX slice counts the model was compiled with. |

## Module Attributes

| Name | Type | Description |
| --- | --- | --- |
| [`DEFAULT_SUPER_SHAVES`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/rvc2/exporter.md#exporter-Module-Attributes-DEFAULT_SUPER_SHAVES) | `int` |  |
| [`OV_2021`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/rvc2/exporter.md#exporter-Module-Attributes-OV_2021) | `bool` |  |

### constant `DEFAULT_SUPER_SHAVES`

```python
DEFAULT_SUPER_SHAVES: int = 8
```

### constant `OV_2021`

```python
OV_2021: bool = env.get('VERSION') == '2021.4.0'
```
