accelerator.py Source File

accelerator.py Source File#

Runtime Library: accelerator.py Source File
Runtime Library v0.30
Mobilint SDK qb
accelerator.py
Go to the documentation of this file.
1
4
5from typing import List
6
7import maccel.maccel as _cMaccel
8from .type import CoreId
9
10__version__: str = _cMaccel.__version__
11
12
15
16
18 """@brief Represents an accelerator, i.e., an NPU, used for executing models."""
19
20 def __init__(self, dev_no: int = 0):
21 """
22 @brief Creates an Accelerator object for a specific device number.
23
24 The `dev_no` parameter represents the device number. For example, on Linux,
25 if an ARIES NPU is attached as `/dev/aries0`, the device number is `0`.
26
27 @param dev_no The device number to associate with the Accelerator.
28 """
29 self._accelerator = _cMaccel.Accelerator(dev_no)
30
31 def get_available_cores(self) -> List[CoreId]:
32 """
33 @brief Retrieves a list of available NPU cores.
34
35 An available core is one that can be allocated for newly created Model objects.
36
37 @note Availability checks are only supported on Linux. On Windows, this function
38 returns all NPU cores without checking availability.
39
40 @return A list containing the IDs of available cores.
41 """
42 return [
43 CoreId.from_cpp(core_id)
44 for core_id in self._accelerator.get_available_cores()
45 ]
46
47
48
Represents an accelerator, i.e., an NPU, used for executing models.
List[CoreId] get_available_cores(self)
Retrieves a list of available NPU cores.
__init__(self, int dev_no=0)
Creates an Accelerator object for a specific device number.