# ModelVariantHandle

```python
class ModelVariantHandle
```

Handle to a specific variant of a loaded model.

This class provides access to variant-specific information such as input/output shapes, buffer information, and quantization scales. It also offers APIs for managing inference buffers, consistent with the interface of the [`Model`](<https://docs.mobilint.com/runtime/kr/v1.2/api/python/Model/index.md>) class.

Objects of this class are obtained via [`Model.get_model_variant_handle()`](<https://docs.mobilint.com/runtime/kr/v1.2/api/python/Model/#get-model-variant-handle>).

## Methods

| Name | Description |
| --- | --- |
| [`__init__`](<#init>) |  |
| [`from_cpp`](<#from-cpp>) |  |
| [`get_variant_idx`](<#get-variant-idx>) | Returns the index of this model variant. |
| [`get_model_input_shape`](<#get-model-input-shape>) | Returns the input shape for this model variant. |
| [`get_model_output_shape`](<#get-model-output-shape>) | Returns the output shape for this model variant. |
| [`get_input_buffer_info`](<#get-input-buffer-info>) | Returns the input buffer information for this variant. |
| [`get_output_buffer_info`](<#get-output-buffer-info>) | Returns the output buffer information for this variant. |
| [`get_input_scale`](<#get-input-scale>) | Returns the input quantization scale(s) for this variant. |
| [`get_output_scale`](<#get-output-scale>) | Returns the output quantization scale(s) for this variant. |
| [`get_model_input_data_type`](<#get-model-input-data-type>) | Returns the input buffer information for the model. |
| [`get_model_output_data_type`](<#get-model-output-data-type>) | Returns the output buffer information of the model. |
| [`acquire_input_buffer`](<#acquire-input-buffer>) | [Buffer](<https://docs.mobilint.com/runtime/kr/v1.2/api/python/Buffer/index.md>) Management API |
| [`acquire_output_buffer`](<#acquire-output-buffer>) | [Buffer](<https://docs.mobilint.com/runtime/kr/v1.2/api/python/Buffer/index.md>) Management API |
| [`release_buffer`](<#release-buffer>) | [Buffer](<https://docs.mobilint.com/runtime/kr/v1.2/api/python/Buffer/index.md>) Management API |
| [`reposition_inputs`](<#reposition-inputs>) | Reposition input |
| [`reposition_outputs`](<#reposition-outputs>) | Reposition output |

### \_\_init\_\_

```python
def __init__(self, _model_variant_handle: _cQbRuntime.ModelVariantHandle)
```

### from\_cpp

```python
def from_cpp(cls, _model_variant_handle: _cQbRuntime.ModelVariantHandle)
```

### get\_variant\_idx

```python
def get_variant_idx(self) -> int
```

Returns the index of this model variant.

**Returns**

Index of the model variant.

### get\_model\_input\_shape

```python
def get_model_input_shape(self) -> List[_Shape]
```

Returns the input shape for this model variant.

**Returns**

model variant's input shape.

### get\_model\_output\_shape

```python
def get_model_output_shape(self) -> List[_Shape]
```

Returns the output shape for this model variant.

**Returns**

model variant's output shape.

### get\_input\_buffer\_info

```python
def get_input_buffer_info(self) -> List[BufferInfo]
```

Returns the input buffer information for this variant.

**Returns**

A list of input buffer information.

### get\_output\_buffer\_info

```python
def get_output_buffer_info(self) -> List[BufferInfo]
```

Returns the output buffer information for this variant.

**Returns**

A list of output buffer information.

### get\_input\_scale

```python
def get_input_scale(self) -> List[Scale]
```

Returns the input quantization scale(s) for this variant.

**Returns**

A list of input scales.

### get\_output\_scale

```python
def get_output_scale(self) -> List[Scale]
```

Returns the output quantization scale(s) for this variant.

**Returns**

A list of output scales.

### get\_model\_input\_data\_type

```python
def get_model_input_data_type(self) -> DataType
```

Returns the input buffer information for the model.

**Returns**

A list of input buffer information.

### get\_model\_output\_data\_type

```python
def get_model_output_data_type(self) -> DataType
```

Returns the output buffer information of the model.

**Returns**

A list of output buffer information.

### acquire\_input\_buffer

```python
def acquire_input_buffer(self, seqlens: List[List[int]] = []) -> List[Buffer]
```

[Buffer](<https://docs.mobilint.com/runtime/kr/v1.2/api/python/Buffer/index.md>) Management API

Acquires list of [`Buffer`](<https://docs.mobilint.com/runtime/kr/v1.2/api/python/Buffer/index.md>) for input. These API is required when calling [`Model.infer_buffer()`](<https://docs.mobilint.com/runtime/kr/v1.2/api/python/Model/#infer-buffer>).

> [!NOTE]
>
> These APIs are intended for advanced use and follow the same buffer management interface as the [`Model`](<https://docs.mobilint.com/runtime/kr/v1.2/api/python/Model/index.md>) class.

### acquire\_output\_buffer

```python
def acquire_output_buffer(self, seqlens: List[List[int]] = []) -> List[Buffer]
```

[Buffer](<https://docs.mobilint.com/runtime/kr/v1.2/api/python/Buffer/index.md>) Management API

Acquires list of [`Buffer`](<https://docs.mobilint.com/runtime/kr/v1.2/api/python/Buffer/index.md>) for output. These API is required when calling [`Model.infer_buffer()`](<https://docs.mobilint.com/runtime/kr/v1.2/api/python/Model/#infer-buffer>).

> [!NOTE]
>
> These APIs are intended for advanced use and follow the same buffer management interface as the [`Model`](<https://docs.mobilint.com/runtime/kr/v1.2/api/python/Model/index.md>) class.

### release\_buffer

```python
def release_buffer(self, buffer: List[Buffer]) -> None
```

[Buffer](<https://docs.mobilint.com/runtime/kr/v1.2/api/python/Buffer/index.md>) Management API

Deallocate acquired Input/Output buffer

> [!NOTE]
>
> These APIs are intended for advanced use and follow the same buffer management interface as the [`Model`](<https://docs.mobilint.com/runtime/kr/v1.2/api/python/Model/index.md>) class.

### reposition\_inputs

```python
def reposition_inputs(
    self,
    inputs: List[np.ndarray],
    input_bufs: List[Buffer],
    seqlens: List[List[int]] = [],
) -> None
```

Reposition input

### reposition\_outputs

```python
def reposition_outputs(
    self,
    output_bufs: List[Buffer],
    outputs: List[np.ndarray],
    seqlens: List[List[int]] = [],
) -> None
```

Reposition output
