# Accelerator

```python
class Accelerator
```

Represents an accelerator, i.e., an NPU, used for executing models.

## Methods

| Name | Description |
| --- | --- |
| [`__init__`](<#init>) | Creates an [Accelerator](<https://docs.mobilint.com/runtime/kr/v1.3/api/python/Accelerator/index.md>) object for a specific device number. |
| [`allocate_pinned_memory`](<#allocate-pinned-memory>) | Allocates an NPU-accessible pinned memory buffer. |

### \_\_init\_\_

```python
def __init__(self, dev_no: int = 0)
```

Creates an [Accelerator](<https://docs.mobilint.com/runtime/kr/v1.3/api/python/Accelerator/index.md>) object for a specific device number.

The `dev_no` parameter represents the device number. For example, on Linux, if an ARIES NPU is attached as `/dev/aries0`, the device number is `0`.

**Parameters**

- `dev_no` — The device number to associate with the [Accelerator](<https://docs.mobilint.com/runtime/kr/v1.3/api/python/Accelerator/index.md>).

### allocate\_pinned\_memory

```python
def allocate_pinned_memory(
    self, shape: Sequence[int], dtype: np.dtype
) -> PinnedMemory
```

Allocates an NPU-accessible pinned memory buffer.

The returned buffer can be used as input or output for zero-copy inference via [`Model.infer_pinned_memory`](<https://docs.mobilint.com/runtime/kr/v1.3/api/python/Model/#infer-pinned-memory>).

> [!NOTE]
>
> This is an experimental API and is only supported on Regulus hardware.

**Parameters**

- `shape` — The shape of the buffer to allocate.
- `dtype` — The element type of the buffer. Must be `numpy.float32` or `numpy.uint8`.

**Returns**

A [PinnedMemory](<https://docs.mobilint.com/runtime/kr/v1.3/api/python/PinnedMemory/index.md>) wrapping the allocated buffer.
