Accelerator Class Reference

Accelerator Class Reference#

SDK qb Runtime Library: mobilint::Accelerator Class Reference
SDK qb Runtime Library v1.3
MCS001-EN

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

#include <acc.h>

Public Member Functions

 Accelerator (const Accelerator &other)=delete
 Accelerator (Accelerator &&other) noexcept
Acceleratoroperator= (const Accelerator &rhs)=delete
Acceleratoroperator= (Accelerator &&rhs) noexcept
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.
 ~Accelerator ()
 Destroys the Accelerator object and releases resources.

Static Public Member Functions

static std::unique_ptr< Acceleratorcreate (StatusCode &sc)
 Creates an Accelerator object for executing models, using device number 0.
static std::unique_ptr< Acceleratorcreate (int dev_no, StatusCode &sc)
 Creates an Accelerator object for a specific device.
static std::unique_ptr< Acceleratorcreate (int dev_no, bool verbose, StatusCode &sc)

Friends

class Model

Detailed Description

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

Definition at line 36 of file acc.h.

Member Function Documentation

◆ create() [1/3]

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

Creates an Accelerator 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
[out]scReference to a StatusCode that will be updated with the result of the creation.
Returns
A unique pointer to the created Accelerator object.

◆ create() [2/3]

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

Creates an Accelerator 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_noThe device number to associate with the Accelerator.
[out]scReference to a StatusCode that will be updated with the result of the creation.
Returns
A unique pointer to the created Accelerator object.

◆ create() [3/3]

std::unique_ptr< Accelerator > mobilint::Accelerator::create ( int dev_no,
bool verbose,
StatusCode & sc )
static
Deprecated
Use std::unique_ptr<Accelerator> create(int dev_no, StatusCode& sc) instead.

◆ allocatePinnedMemory()

template<typename T>
PinnedMemory< T > mobilint::Accelerator::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
TElement type of the buffer. Currently only uint8_t and float are supported.
Parameters
[in]shapeBuffer shape. All dimensions must be positive.
[out]scReference to a StatusCode that will be updated with the result of the allocation.
Returns
The allocated PinnedMemory handle. On failure the handle is empty and sc holds the error code.

◆ Model

friend class Model
friend

Definition at line 108 of file acc.h.


The documentation for this class was generated from the following file: