# Accelerator

```cpp
#include <qbruntime/acc.h>

class mobilint::Accelerator
```

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

## Static functions

| Member | Description |
| --- | --- |
| [`create`](<#create>) ×3 | Creates an [Accelerator](<https://docs.mobilint.com/runtime/kr/v1.3/api/cpp/accelerator/index.md>) object for executing models, using device number 0. |

### create

```cpp
static std::unique_ptr<Accelerator> create(StatusCode &sc)
```

Creates an [Accelerator](<https://docs.mobilint.com/runtime/kr/v1.3/api/cpp/accelerator/index.md>) object for executing models, using device number 0.

This function is useful when only one device is attached, in which case the default device (device 0) will be used.

**Parameters**

- `sc` *\[out\]* — Reference to a [StatusCode](<https://docs.mobilint.com/runtime/kr/v1.3/api/cpp/#statuscode>) that will be updated with the result of the creation.

**Returns**

A unique pointer to the created [Accelerator](<https://docs.mobilint.com/runtime/kr/v1.3/api/cpp/accelerator/index.md>) object.

```cpp
static std::unique_ptr<Accelerator> create(int dev_no, StatusCode &sc)
```

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

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/cpp/accelerator/index.md>).
- `sc` *\[out\]* — Reference to a [StatusCode](<https://docs.mobilint.com/runtime/kr/v1.3/api/cpp/#statuscode>) that will be updated with the result of the creation.

**Returns**

A unique pointer to the created [Accelerator](<https://docs.mobilint.com/runtime/kr/v1.3/api/cpp/accelerator/index.md>) object.

```cpp
static std::unique_ptr<Accelerator> create(int dev_no, bool verbose, StatusCode &sc)
```

> [!WARNING]
>
> **Deprecated**
>
> Use [`std::unique_ptr<Accelerator> create(int dev_no, StatusCode& sc)`](<https://docs.mobilint.com/runtime/kr/v1.3/api/cpp/accelerator/index.md>) instead.

## Member functions

| Member | Description |
| --- | --- |
| [`Accelerator`](<#accelerator>) ×2 |  |
| [`operator=`](<#operator-assign>) ×2 |  |
| [`allocatePinnedMemory`](<#allocatepinnedmemory>) | Allocates a pinned (zero-copy) memory buffer on the NPU device. |

### Accelerator

```cpp
Accelerator(const Accelerator &other)=delete
```

```cpp
Accelerator(Accelerator &&other) noexcept
```

### operator=

```cpp
Accelerator & operator=(const Accelerator &rhs)=delete
```

```cpp
Accelerator & operator=(Accelerator &&rhs) noexcept
```

### allocatePinnedMemory

```cpp
template <typename T>
PinnedMemory<T> allocatePinnedMemory(const std::vector<int64_t> &shape, StatusCode &sc)
```

Allocates a pinned (zero-copy) memory buffer on the NPU device.

The returned buffer is mapped into both host and NPU address space so that inference can read/write it directly without an intermediate copy. Only supported on Regulus SoC hardware (excluding USB); other targets return `Model_IsNotSupportedHardware`.

**Template parameters**

- `T` — Element type of the buffer. Currently only `uint8_t` and `float` are supported.

**Parameters**

- `shape` *\[in\]* — [Buffer](<https://docs.mobilint.com/runtime/kr/v1.3/api/cpp/buffer/index.md>) shape. All dimensions must be positive.
- `sc` *\[out\]* — Reference to a [StatusCode](<https://docs.mobilint.com/runtime/kr/v1.3/api/cpp/#statuscode>) that will be updated with the result of the allocation.

**Returns**

The allocated [PinnedMemory](<https://docs.mobilint.com/runtime/kr/v1.3/api/cpp/pinnedmemory/index.md>) handle. On failure the handle is empty and `sc` holds the error code.
