qbruntime.accelerator.Accelerator Class Reference#
|
SDK qb Runtime Library v1.4
MCS001-KR
|
Represents an accelerator, i.e., an NPU, used for executing models. More...
Public Member Functions | |
| __init__ (self, int dev_no=0) | |
| __init__ (self, str device_name="auto") | |
| __init__ (self, str device_name="auto", int dev_no=0) | |
| __init__ (self, device_name="auto", dev_no=0) | |
| Creates an Accelerator object for a specific target device and device number. | |
| str | get_device_name (self) |
| Returns the resolved device name of this accelerator. | |
| PinnedMemory | allocate_pinned_memory (self, Sequence[int] shape, np.dtype dtype) |
| Allocates an NPU-accessible pinned memory buffer. | |
Protected Attributes | |
| _accelerator = _cQbRuntime.Accelerator(device_name, dev_no) | |
Detailed Description
Represents an accelerator, i.e., an NPU, used for executing models.
- Attention
- For the regulus-usb device family, do not unplug the USB device while the runtime is running. Disconnecting a device that is in use may crash the program or cause unexpected misbehavior.
Definition at line 17 of file accelerator.py.
Constructor & Destructor Documentation
◆ __init__() [1/4]
| qbruntime.accelerator.Accelerator.__init__ | ( | self, | |
| int | dev_no = 0 ) |
Definition at line 27 of file accelerator.py.
◆ __init__() [2/4]
| qbruntime.accelerator.Accelerator.__init__ | ( | self, | |
| str | device_name = "auto" ) |
Definition at line 30 of file accelerator.py.
◆ __init__() [3/4]
| qbruntime.accelerator.Accelerator.__init__ | ( | self, | |
| str | device_name = "auto", | ||
| int | dev_no = 0 ) |
Definition at line 33 of file accelerator.py.
◆ __init__() [4/4]
| qbruntime.accelerator.Accelerator.__init__ | ( | self, | |
| device_name = "auto", | |||
| dev_no = 0 ) |
Creates an Accelerator object for a specific target device and device number.
The device_name parameter selects target device to open; case-insensitive. Supported values:
- "auto"
- "aries", "aries-rb"
- "regulus", "regulus-usb"
- "regulus-ra", "regulus-ra-usb"
- "regulus-rb", "regulus-rb-usb"
Automatic resolution:
- "auto" resolves the target device automatically, but only when exactly one supported kind of target device is present in the system.
- A base name ("aries", "regulus", "regulus-usb", ...) is a shorthand for every target device whose name begins with it (e.g. "aries" matches "aries-rb"). It resolves to the concrete target device automatically, but only when exactly one such matching target device is present.
The dev_no parameter is the device number. For example, on Linux an ARIES NPU attached as /dev/aries0 has device number 0.
- Parameters
-
[in] device_name Device name to open (case-insensitive). See the list above. [in] dev_no The device number to associate with the Accelerator.
- Exceptions
-
QbRuntimeError If device_nameis unknown, if auto-resolution is ambiguous (more than one candidate), or if no matching device exists.
- Note
- Supported constructor forms:
- Accelerator(): auto-select the only attached NPU.
- Accelerator(dev_no): auto-detect device, open target device dev_no.
- Accelerator(device_name): open device_name at device 0.
- Accelerator(device_name, dev_no): open device_name at device dev_no.
Definition at line 35 of file accelerator.py.
Member Function Documentation
◆ get_device_name()
| str qbruntime.accelerator.Accelerator.get_device_name | ( | self | ) |
Returns the resolved device name of this accelerator.
When created with a automatic resolve such as "auto", "aries", this returns the real target device name that was resolved (e.g. "aries-rb", "regulus-ra-usb").
- Returns
- The resolved device name.
Definition at line 74 of file accelerator.py.
◆ allocate_pinned_memory()
| PinnedMemory qbruntime.accelerator.Accelerator.allocate_pinned_memory | ( | self, | |
| Sequence[int] | shape, | ||
| np.dtype | dtype ) |
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 device.
- 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.
Definition at line 86 of file accelerator.py.
Member Data Documentation
◆ _accelerator
|
protected |
Definition at line 72 of file accelerator.py.
The documentation for this class was generated from the following file:
Generated by