Python API Reference

Python API Reference#

Runtime Library: Python API Reference
Runtime Library v0.30
Mobilint SDK qb
Python API Reference

Python API provides wrapper functions for C++ implemented library. More...

Classes

class  maccel.accelerator.Accelerator
 Represents an accelerator, i.e., an NPU, used for executing models. More...
class  maccel.future.Future
 Represents a future for retrieving the result of asynchronous inference. More...
class  maccel.model.Model
 Represents an AI model loaded from an MXQ file. More...
class  maccel.model_variant_handle.ModelVariantHandle
 Handle to a specific variant of a loaded model. More...
class  maccel.type.Cluster
 Enumerates clusters in the ARIES NPU. More...
class  maccel.type.Core
 Enumerates cores within a cluster in the ARIES NPU. More...
class  maccel.type.CoreAllocationPolicy
 Core allocation policy. More...
class  maccel.type.LatencySetPolicy
class  maccel.type.MaintenancePolicy
class  maccel.type.SchedulePolicy
class  maccel.type.Scale
 Struct for scale values. More...
class  maccel.type.CoreId
 Represents a unique identifier for an NPU core. More...
class  maccel.type.Buffer
 A simple byte-sized buffer. More...
class  maccel.type.CoreMode
 Defines the core mode for NPU execution. More...
class  maccel.type.BufferInfo
 Struct representing input/output buffer information. More...
class  maccel.type.ModelConfig
 Configures a core mode and core allocation of a model for NPU inference. More...
class  maccel.type.LogLevel
 LogLevel. More...
class  maccel.type.CacheType
 CacheType. More...
class  maccel.type.CacheInfo
 Struct representing KV-cache information. More...

Functions

bool maccel.model._is_valid_shape (_Shape input_shape, _Shape shape)
Optional[bool] maccel.model._is_shape_hwc (List[np.ndarray] inputs, List[_Shape] shapes)
Tuple[int, bool] maccel.model._find_matching_variant_idx_and_is_hwc (model, List[np.ndarray] inputs)
List[np.ndarray] maccel.model._build_outputs (List[_Shape] shapes, bool is_hwc, np.dtype dtype)
None maccel.model._check_output_shapes (List[np.ndarray] outputs, List[_Shape] shapes, bool is_hwc, np.dtype dtype)
Model maccel.model.load (str path, Optional[ModelConfig] model_config=None)
 Single-step inference API.
 maccel.type.set_log_level (LogLevel level)
bool maccel.type.start_tracing_events (str path)
 Starts event tracing and prepares to save the trace log to a specified file.
 maccel.type.stop_tracing_events ()
 Stops event tracing and writes the recorded trace log.
str maccel.type.get_model_summary (str mxq_path)
 Generates a structured summary of the specified MXQ model.

Detailed Description

Python API provides wrapper functions for C++ implemented library.

Function Documentation

◆ _is_valid_shape()

bool maccel.model._is_valid_shape ( _Shape input_shape,
_Shape shape )
protected

Definition at line 25 of file model.py.

◆ _is_shape_hwc()

Optional[bool] maccel.model._is_shape_hwc ( List[np.ndarray] inputs,
List[_Shape] shapes )
protected

Definition at line 39 of file model.py.

◆ _find_matching_variant_idx_and_is_hwc()

Tuple[int, bool] maccel.model._find_matching_variant_idx_and_is_hwc ( model,
List[np.ndarray] inputs )
protected

Definition at line 58 of file model.py.

◆ _build_outputs()

List[np.ndarray] maccel.model._build_outputs ( List[_Shape] shapes,
bool is_hwc,
np.dtype dtype )
protected

Definition at line 78 of file model.py.

◆ _check_output_shapes()

None maccel.model._check_output_shapes ( List[np.ndarray] outputs,
List[_Shape] shapes,
bool is_hwc,
np.dtype dtype )
protected

Definition at line 92 of file model.py.

◆ load()

Model maccel.model.load ( str path,
Optional[ModelConfig] model_config = None )

Single-step inference API.

Creates model and uploads the model into NPU immediately.

This operation performs the Accelerator declaration, Model declaration, and launch in a single step.

Definition at line 668 of file model.py.

◆ set_log_level()

maccel.type.set_log_level ( LogLevel level)

Definition at line 774 of file type.py.

◆ start_tracing_events()

bool maccel.type.start_tracing_events ( str path)

Starts event tracing and prepares to save the trace log to a specified file.

The trace log is recorded in "Chrome Tracing JSON format," which can be viewed at https://ui.perfetto.dev/.

The trace log is not written immediately; it is saved only when stop_tracing_events() is called.

Parameters
[in]pathThe file path where the trace log should be stored.
Returns
True if tracing starts successfully, False otherwise.

Definition at line 855 of file type.py.

◆ stop_tracing_events()

maccel.type.stop_tracing_events ( )

Stops event tracing and writes the recorded trace log.

This function finalizes tracing and saves the collected trace data to the file specified when start_tracing_events() was called.

Definition at line 871 of file type.py.

◆ get_model_summary()

str maccel.type.get_model_summary ( str mxq_path)

Generates a structured summary of the specified MXQ model.

Returns an overview of the model contained in the MXQ file, including:

  • Target NPU hardware
  • Supported core modes and their associated cores
  • The total number of model variants
  • For each variant:
    • Input and output tensor shapes
    • A list of layers with their types, output shapes, and input layer indices

The summary is returned as a human-readable string in a table and is useful for inspecting model compatibility, structure, and input/output shapes.

Parameters
[in]mxq_pathPath to the MXQ model file.
Returns
A formatted string containing the model summary.

Definition at line 881 of file type.py.