Skip to content

Accelerator

class Accelerator

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

Methods

Name Description
__init__ Creates an Accelerator object for a specific device number.
allocate_pinned_memory Allocates an NPU-accessible pinned memory buffer.

__init__

def __init__(self, dev_no: int = 0)

Creates an Accelerator 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.

allocate_pinned_memory

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.

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 wrapping the allocated buffer.