Accelerator API (Python-wrapped MxAccl)#

class MxAccl#

Python binding of the MxAccl class (auto-threading)

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: memryx.runtime.mxapi.MxAccl, dfp_path: os.PathLike, device_ids_to_use: list[int] = [0], use_model_shape: Annotated[list[bool], FixedSize(2)] = [True, True], local_mode: bool = False, sched_options: memryx.runtime.mxapi.SchedulerOptions = <memryx.runtime.mxapi.SchedulerOptions object at 0x7f2b0caed9f0>, client_options: memryx.runtime.mxapi.ClientOptions = <memryx.runtime.mxapi.ClientOptions object at 0x7f2b0caedb70>, server_addr: str = '/run/mxa_manager/', server_port_base: int = 10000, ignore_server: bool = False) -> None

  2. __init__(self: memryx.runtime.mxapi.MxAccl, dfp_bytes: bytes, dfp_bytes_size: int, device_ids_to_use: list[int] = [0], use_model_shape: Annotated[list[bool], FixedSize(2)] = [True, True], local_mode: bool = False, sched_options: memryx.runtime.mxapi.SchedulerOptions = <memryx.runtime.mxapi.SchedulerOptions object at 0x7f2b0caed830>, client_options: memryx.runtime.mxapi.ClientOptions = <memryx.runtime.mxapi.ClientOptions object at 0x7f2b0caed7f0>, server_addr: str = '/run/mxa_manager/', server_port_base: int = 10000, ignore_server_: bool = False) -> None

    Initializes the MxAccl object by loading a DFP from a file (1st version) or from raw bytes (2nd version).

Parameters:
dfp_pathstr

Path to the DFP file.

dfp_bytesbytes

DFP as raw bytes object.

dfp_bytes_sizeint

Size of the DFP bytes.

device_ids_to_useList[int], optional

List of device IDs to use. Set to [-1] to use all available devices. Default is [0].

use_model_shapeTuple[bool, bool], optional

Whether to use model shape for input and output feature maps. Default is (True, True).

local_modebool, optional

Whether to run in local mode without connecting to server. Default is False.

sched_optionsSchedulerOptions, optional

Scheduler options for this client. Default is SchedulerOptions().

client_optionsClientOptions, optional

Client options for this client. Default is ClientOptions().

server_addrstr, optional

Server address to connect to (e.g., “/run/mxa_manager/”). Default is “/run/mxa_manager/”.

server_port_baseint, optional

Base port number for server connection. Default is 10000.

ignore_serverbool, optional

Whether to ignore server connection and run without it (DANGER). Default is False.

3. ``__init__(self: memryx.runtime.mxapi.MxAccl, *args, **kwargs) -> None``
can_get_power_consumption(self: memryx.runtime.mxapi.MxAccl, device_id: int) → bool#

Checks if the given device is able to report power consumption data.

Parameters:
device_idint

The ID of the device to check.

Returns:
bool

True if power consumption data can be retrieved for the device, False otherwise.

connect_post_model(self: memryx.runtime.mxapi.MxAccl, post_model_path: os.PathLike, model_id: int = 0, post_size_list: list[int] = []) → None#

Connects a post-processing model to the specified model ID.

Parameters:
post_model_pathstr

The file path to the post-processing model.

model_idint, optional

The ID of the model to connect to. Default is 0.

connect_pre_model(self: memryx.runtime.mxapi.MxAccl, pre_model_path: os.PathLike, model_id: int = 0) → None#

Connects a pre-processing model to the specified model ID.

Parameters:
pre_model_pathstr

The file path to the pre-processing model.

model_idint, optional

The ID of the model to connect to. Default is 0.

connect_stream(self: memryx.runtime.mxapi.MxAccl, in_callback: object, out_callback: object, stream_id: int, model_id: int = 0) → None#

Connects a stream to a model using the specified input and output callbacks functions.

This method registers a data stream for the given model and binds it to both input and output callback functions. Streams uniquely identified by stream_id can be connected to the same model. This function must be called before start().

The provided input callback function should have the following signature, where the return value is either a list of numpy arrays or None.

`python def in_callback(stream_id: int) -> List[np.ndarray]: `

And the output callback function should have the following signature:

`python def out_callback(ofmaps: List[np.ndarray], stream_id: int) -> None: `

Parameters:
in_callbackCallable[[int], Optional[List[np.ndarray]]]

A Python callable that takes a stream ID as input and returns a list of numpy arrays to the MXA, or None to indicate the end of the stream.

out_callbackCallable[[List[np.ndarray], int], None]

A Python callable that takes a list of numpy arrays (ofmaps from the MXA) and a stream ID as input.

stream_idint

An integer identifier for the stream. This can be used to differentiate multiple streams connected to the same model.

model_idint, optional

The ID of the model to connect the stream to. Default is 0.

curr_ofmap_queue_size(self: memryx.runtime.mxapi.MxAccl) → int#
from_device(self: memryx.runtime.mxapi.MxAccl) → int#
get_chip_temperatures(self: memryx.runtime.mxapi.MxAccl, device_id: int) → numpy.ndarray[numpy.float32]#

Gets the current temperature of each chip on the specified device in Celsius.

Parameters:
device_idint

The ID of the device to query.

Returns:
List[float]

A list of current temperatures in Celsius for each chip on the device.

get_max_temperature(self: memryx.runtime.mxapi.MxAccl, device_id: int) → float#

Gets the current maximum temperature among all chips on the specified device in Celsius.

Parameters:
device_idint

The ID of the device to query.

Returns:
float

The current maximum temperature in Celsius. Returns -1 if temperature data is unavailable.

get_model_info(self: memryx.runtime.mxapi.MxAccl, model_id: int = 0) → memryx.runtime.mxapi.MxModelInfo#

Returns model metadata for the requested DFP model.

get_num_models(self: memryx.runtime.mxapi.MxAccl) → int#

Returns the number of models in the compiled DFP.

get_post_model_info(self: memryx.runtime.mxapi.MxAccl, model_id: int = 0) → memryx.runtime.mxapi.MxModelInfo#

Returns metadata for the connected post-processing model.

get_power(self: memryx.runtime.mxapi.MxAccl, device_id: int) → float#

Gets the current power consumption of the specified device in mW.

Parameters:
device_idint

The ID of the device to query.

Returns:
float

The current power consumption in milliwatts (mW). Returns -1 if power data is unavailable.

get_pre_model_info(self: memryx.runtime.mxapi.MxAccl, model_id: int = 0) → memryx.runtime.mxapi.MxModelInfo#

Returns metadata for the connected pre-processing model.

get_raw_ptr(self: memryx.runtime.mxapi.MxAccl) → int#
set_operating_frequency(self: memryx.runtime.mxapi.MxAccl, device_id: int, freq: int) → bool#

Sets the operating frequency of the specified device.

Parameters:
device_idint

The ID of the device to set the frequency for.

freqint

The desired operating frequency in MHz. Must be a valid 25MHz step between 200 and 1000.

Returns:
bool

True if the frequency was successfully set, False otherwise.

start(self: memryx.runtime.mxapi.MxAccl, model_id: int = -1) → None#

Starts the execution of the specified model, or all models in the DFP if model_id is -1.

Parameters:
model_idint, optional

The ID of the model to start. If -1, starts all models in the DFP. Default is -1.

suggested_max_pending_frames(self: memryx.runtime.mxapi.MxAccl) → int#
wait(self: memryx.runtime.mxapi.MxAccl, model_id: int = -1) → None#

Blocks until all streams for the specified model(s) have completed execution.

Parameters:
model_idint, optional

The ID of the model to wait for. If -1, waits for all models in the DFP. Default is -1.

class MxAcclMT#

Python binding of the MxAcclMT class (manual-threading)

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: memryx.runtime.mxapi.MxAcclMT, dfp_path: os.PathLike, device_ids_to_use: list[int] = [0], use_model_shape: Annotated[list[bool], FixedSize(2)] = [True, True], local_mode: bool = False, sched_options: memryx.runtime.mxapi.SchedulerOptions = <memryx.runtime.mxapi.SchedulerOptions object at 0x7f2b0cadc6f0>, client_options: memryx.runtime.mxapi.ClientOptions = <memryx.runtime.mxapi.ClientOptions object at 0x7f2b0cadc5b0>, server_addr: str = '/run/mxa_manager/', server_port_base: int = 10000, ignore_server: bool = False) -> None

  2. __init__(self: memryx.runtime.mxapi.MxAcclMT, dfp_bytes: bytes, dfp_bytes_size: int, device_ids_to_use: list[int] = [0], use_model_shape: Annotated[list[bool], FixedSize(2)] = [True, True], local_mode: bool = False, sched_options: memryx.runtime.mxapi.SchedulerOptions = <memryx.runtime.mxapi.SchedulerOptions object at 0x7f2b0cadd8b0>, client_options: memryx.runtime.mxapi.ClientOptions = <memryx.runtime.mxapi.ClientOptions object at 0x7f2b0caeeb70>, server_addr: str = '/run/mxa_manager/', server_port_base: int = 10000, ignore_server_: bool = False) -> None

  3. __init__(self: memryx.runtime.mxapi.MxAcclMT, *args, **kwargs) -> None

can_get_power_consumption(self: memryx.runtime.mxapi.MxAcclMT, device_id: int) → bool#

Checks if the given device is able to report power consumption data.

Parameters:
device_idint

The ID of the device to check.

Returns:
bool

True if power consumption data can be retrieved for the device, False otherwise.

connect_post_model(self: memryx.runtime.mxapi.MxAcclMT, post_model_path: os.PathLike, model_id: int = 0, post_size_list: list[int] = []) → None#

Connects a post-processing model to the specified model ID.

Parameters:
post_model_pathstr

The file path to the post-processing model.

model_idint, optional

The ID of the model to connect to. Default is 0.

connect_pre_model(self: memryx.runtime.mxapi.MxAcclMT, pre_model_path: os.PathLike, model_id: int = 0) → None#

Connects a pre-processing model to the specified model ID.

Parameters:
pre_model_pathstr

The file path to the pre-processing model.

model_idint, optional

The ID of the model to connect to. Default is 0.

get_chip_temperatures(self: memryx.runtime.mxapi.MxAcclMT, device_id: int) → numpy.ndarray[numpy.float32]#

Gets the current temperature of each chip on the specified device in Celsius.

Parameters:
device_idint

The ID of the device to query.

Returns:
List[float]

A list of current temperatures in Celsius for each chip on the device.

get_max_temperature(self: memryx.runtime.mxapi.MxAcclMT, device_id: int) → float#

Gets the current maximum temperature among all chips on the specified device in Celsius.

Parameters:
device_idint

The ID of the device to query.

Returns:
float

The current maximum temperature in Celsius. Returns -1 if temperature data is unavailable.

get_model_info(self: memryx.runtime.mxapi.MxAcclMT, model_id: int = 0) → memryx.runtime.mxapi.MxModelInfo#

Returns model metadata for the requested DFP model.

get_num_models(self: memryx.runtime.mxapi.MxAcclMT) → int#

Returns the number of models in the compiled DFP.

get_post_model_info(self: memryx.runtime.mxapi.MxAcclMT, model_id: int = 0) → memryx.runtime.mxapi.MxModelInfo#

Returns metadata for the connected post-processing model.

get_power(self: memryx.runtime.mxapi.MxAcclMT, device_id: int) → float#

Gets the current power consumption of the specified device in mW.

Parameters:
device_idint

The ID of the device to query.

Returns:
float

The current power consumption in milliwatts (mW). Returns -1 if power data is unavailable.

get_pre_model_info(self: memryx.runtime.mxapi.MxAcclMT, model_id: int = 0) → memryx.runtime.mxapi.MxModelInfo#

Returns metadata for the connected pre-processing model.

receive_output(self: memryx.runtime.mxapi.MxAcclMT, stream_id: int, model_id: int = 0, timeout: int = 0) → list[numpy.ndarray[numpy.float32]]#

Receives output data from the accelerator for the specified model and stream.

Parameters:
stream_idint

The ID of the stream to receive the output from.

model_idint

The ID of the model to receive the output from. Default is 0.

timeoutint, optional

The maximum time to wait for the output to be received, in milliseconds. Default is 0 (no timeout).

Returns:
List[np.ndarray]

The output feature maps received from the accelerator. Returns None if there was a timeout or error.

run(self: memryx.runtime.mxapi.MxAcclMT, in_data: object, stream_id: int, model_id: int = 0, timeout: int = 0) → list[numpy.ndarray[numpy.float32]]#

Runs inference on a batch of inputs and returns the resulting the outputs.

WARNING! While convenient for simple use cases, this method has much worse performance than using send_input and receive_output in separate threads. Separate threads are necessary to fully utilize the MXA’s pipelined architecture. Real-time applications should never use this function.

Parameters:
in_dataList[np.ndarray] or np.ndarray

The input feature maps to send.

stream_idint

The ID of the stream to run inference on.

model_idint

The ID of the model to run inference on. Default is 0.

timeoutint, optional

The maximum time to wait for the inference to complete, in milliseconds. Default is 0 (no timeout).

Returns:
List[np.ndarray]

The output feature maps received from the accelerator. Returns None if there was a timeout or error.

send_input(self: memryx.runtime.mxapi.MxAcclMT, in_data: object, stream_id: int, model_id: int = 0, timeout: int = 0) → None#

Sends input data to the accelerator for the specified model and stream.

Parameters:
in_dataList[np.ndarray] or np.ndarray

The input feature maps to send.

stream_idint

The ID of the stream to send the input to.

model_idint

The ID of the model to send the input to. Default is 0.

timeoutint, optional

The maximum time to wait for the input to be sent, in milliseconds. Default is 0 (no timeout).

Returns:
bool

True if the input was successfully sent, False if there was a timeout or error.

set_operating_frequency(self: memryx.runtime.mxapi.MxAcclMT, device_id: int, freq: int) → bool#

Sets the operating frequency of the specified device.

Parameters:
device_idint

The ID of the device to set the frequency for.

freqint

The desired operating frequency in MHz. Must be a valid 25MHz step between 200 and 1000.

Returns:
bool

True if the frequency was successfully set, False otherwise.

Scheduler and Client Options#

class ModelType#

Members:

NORMAL

PARENT

CHILD

CHILD = <ModelType.CHILD: 2>#
NORMAL = <ModelType.NORMAL: 0>#
PARENT = <ModelType.PARENT: 1>#
property name#
property value#
class SchedulerOptions#

SchedulerOptions encapsulates various options for the scheduler, including frame and time limits, queue sizes, and autoclock settings.

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: memryx.runtime.mxapi.SchedulerOptions) -> None

  2. __init__(self: memryx.runtime.mxapi.SchedulerOptions, max_queue_size: int = 100, driver_depth: int = 4, is_latency_sensitive: bool = False, model_types: list[memryx.runtime.mxapi.ModelType] = [<ModelType.NORMAL: 0>], op_freq: int = 0, autoclock_enabled: bool = False, autoclock_power_limit_mw: int = 11500, autoclock_check_fps_saturation: bool = False, autoclock_sample_interval_ms: int = 50, autoclock_num_samples: int = 6) -> None

  3. __init__(self: memryx.runtime.mxapi.SchedulerOptions, *args, **kwargs) -> None

is_latency_sensitive#

A boolean that selects latency-oriented scheduling. The default is False, which prioritizes throughput. For interactive workloads, set this to True and use MxAccl.suggested_max_pending_frames() in the producer to decide when to drop excess input frames.

property autoclock_check_fps_saturation#

Experimental: If true, autoclocking will stop increasing frequency, even if there’s still power headroom, if FPS has not increased over the last 3 frequency steps. Default: false

property autoclock_enabled#

Enable automatic frequency up/down-clocking when starting DFP, if supposed by the target MX3 hardware. Default: false

property autoclock_num_samples#

Number of power samples to collect (and find the maximum of) before making a decision to stay at the current frequency or increase it. Default: 6

property autoclock_power_limit_mw#

Power limit in milliwatts. Autoclocking will increase frequency until this power limit is reached. Range: [1000, 14700]. Default: 11500 mW

property autoclock_sample_interval_ms#

Interval in milliseconds between power samples while testing autoclocking steps. Default: 50 ms

property driver_depth#

Driver-level buffer depth for ifmap/ofmap transfers to the device. A deeper value may improve throughput at the cost of more memory. Default: 4

property max_queue_size#

Maximum number of feature maps buffered between clients and mxa-manager (applies to both input and output queues). Default: 100.

property model_types#

An array specifying the type of each model in the DFP, with possible values defined by the ModelType enum (NORMAL, PARENT, CHILD). This allows the scheduler to apply different policies or optimizations based on model roles. Default is {ModelType::NORMAL} for all models. MAX_MODELS is set to 32.

Accepts a list shorter than MAX_MODELS (e.g. only the entries you care about); any remaining entries are set to ModelType.NORMAL.

property op_freq#

Operating frequency in MHz (e.g. 600) for this DFP. 0 uses the value in /etc/memryx/power.conf. Cannot be set together with autoclock_enabled. Can be changed later with set_operating_frequency(). Default: 0

class ClientOptions#

Configures client-side execution behavior, such as FPS smoothing.

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: memryx.runtime.mxapi.ClientOptions) -> None

  2. __init__(self: memryx.runtime.mxapi.ClientOptions, fps_target: float = 0.0) -> None

  3. __init__(self: memryx.runtime.mxapi.ClientOptions, *args, **kwargs) -> None

property fps_target#

Target FPS used for frame-rate smoothing. 0 means disabled, any positive value sets the target FPS for smoothing. Default is 0 (disabled).

Advanced Control#

class Client#

Python binding of the MX::Runtime::Client class, which can be used to query information from mxa-manager (such as power, temperature, pressure, etc.) separately from an MxAccl/MxAcclMT instance.

connect_dfp(self: memryx.runtime.mxapi.Client, dfp_bytes: bytes, model_id: int, scheduler_options: memryx.runtime.mxapi.SchedulerOptions, client_options: memryx.runtime.mxapi.ClientOptions, devices_to_use: list[int]) → bool#
end_connection(self: memryx.runtime.mxapi.Client) → bool#

Ends connection to mxa-manager. Should be called to clean up resources when Client is no longer needed.

Returns:
bool

True if connection is successfully closed, False otherwise.

get_avg_max_temp(self: memryx.runtime.mxapi.Client, device_id: int) → float#

Gets the rolling average of the maximum temperatures across all chips on the device.

Parameters:
device_idint

ID of the device to query.

Returns:
float

Average of the maximum temperatures across all chips on the device, in degrees Celsius, over the past HW_MONITOR_INFO (set in /etc/memryx/mxa_manager.conf, default 500ms).

get_avg_power(self: memryx.runtime.mxapi.Client, device_id: int) → float#

Gets the rolling average power consumption of the device, if supported by the device.

Parameters:
device_idint

ID of the device to query.

Returns:
float

Rolling average power consumption of the device in milliwatts (mW) over the past HW_MONITOR_INFO (set in /etc/memryx/mxa_manager.conf, default 500ms), if supported by the device. If not supported, returns -1.

get_device_infos(self: memryx.runtime.mxapi.Client) → list[memryx.runtime.mxapi.device_info_t]#

Gets information about all available MemryX devices from mxa-manager.

Returns:
List[device_info_t]

A list of device_info_t objects, each containing info about that MXA device.

get_device_statuses(self: memryx.runtime.mxapi.Client) → list[memryx.runtime.mxapi.device_status_t]#

Gets the ownership state and available telemetry of all MemryX devices from mxa-manager.

Returns:
List[device_status_t]

A list of device_status_t objects, one per MXA device.

get_inst_max_temp(self: memryx.runtime.mxapi.Client, device_id: int) → float#

Gets the current maximum temperature across all chips on the device.

Parameters:
device_idint

ID of the device to query.

Returns:
float

Current maximum temperature across all chips on the device, in degrees Celsius.

get_inst_power(self: memryx.runtime.mxapi.Client, device_id: int) → float#

Gets the current power consumption of the device, if supported by the device.

Parameters:
device_idint

ID of the device to query.

Returns:
float

Current power consumption of the device in milliwatts (mW), if supported by the device. If not supported, returns -1.

get_pressure(self: memryx.runtime.mxapi.Client, device_id: int) → str#

Gets the current “pressure” level of the device, hinting to the user how many more streams could be assigned to the device before it becomes overloaded.

Parameters:
device_idint

ID of the device to query.

Returns:
str

Current pressure level of the device, returned as a string with possible values: “low”, “medium”, “high”, “full”. See C++ API docs for details on what these levels mean.

init_connection(self: memryx.runtime.mxapi.Client, server_address: str = '/run/mxa_manager/', base_port: int = 10000) → bool#

Initializes connection to mxa-manager. Must be called before any other Client method.

Parameters:
server_addressstr, optional

Address of the mxa-manager server (default: “/run/mxa_manager/”). For local UNIX socket connection, use the format “/path/to/socket”. For TCP connection, use the format “ip_address”.

base_portint, optional

Base port number (TCP) or numeric filename (UNIX) for connecting to mxa-manager (default: 10000).

Returns:
bool

True if connection is successfully established, False otherwise.

local_unlock(self: memryx.runtime.mxapi.Client, device_id: int) → bool#
property my_client_id#

The unique client ID assigned by mxa-manager to this Client instance after a successful call to init_connection.

set_power_mode(self: memryx.runtime.mxapi.Client, device_id: int, freq_mhz: int) → bool#

Sets the operating frequency of the specified device.

Parameters:
device_idint

ID of the device to set the frequency on.

freq_mhzint

Desired operating frequency in MHz. Must be a valid 25MHz step between 200 and 1000.

Returns:
bool

True if the frequency was successfully set, False otherwise (e.g. invalid frequency or device_id).

try_local_lock(self: memryx.runtime.mxapi.Client, device_id: int) → bool#
class device_info_t#

Struct with info about a MemryX device, retrieved from mxa-manager.

property can_get_power_data#

Whether power data can be retrieved from the device. If false, power will always be reported as -1.

property chip_count#

Number of chips in the device.

property chips_per_group#

DEPRECATED Number of chips per group.

property current_config#

DEPRECATED Current ‘group’ configuration of the device.

property freqs#

Frequencies in MHz of each chip on the device. The length of this list should match chip_count.

property is_usb#

Whether the device is connected via USB.

keys() → list[str]#
property num_groups#

DEPRECATED Number of ‘groups’ in the device.

property volt#

Voltage in mV of the device. This applies to all chips on the device.

class device_status_t#

Ownership state and telemetry of a MemryX device, retrieved from mxa-manager.

property frequencies_mhz#
property mode#

Who holds the device: IDLE (unlocked), LOCAL (a local-mode client) or SHARED (mxa-manager).

property power_mw#
property pressure#
property temperature_c#
property valid_fields#
class DeviceMode#

Members:

IDLE

LOCAL

SHARED

RESTART_REQUIRED

IDLE = <DeviceMode.IDLE: 0>#
LOCAL = <DeviceMode.LOCAL: 1>#
RESTART_REQUIRED = <DeviceMode.RESTART_REQUIRED: 3>#
SHARED = <DeviceMode.SHARED: 2>#
property name#
property value#

The client reports device pressure using these thresholds:

MEMX_PRESSURE_LOW_THRESH = 20.0#

Convert a string or number to a floating-point number, if possible.

MEMX_PRESSURE_MEDIUM_THRESH = 65.0#

Convert a string or number to a floating-point number, if possible.

MEMX_PRESSURE_HIGH_THRESH = 92.0#

Convert a string or number to a floating-point number, if possible.

Model and feature-map information#

class DfpObject#
property chip_gen#
property chip_gen_name#
property compile_time#
property compiler_version#
property dfp_byte_size#
property dfp_version#
property dfp_version_str#
get_src_dfp_bytes(self: memryx.runtime.mxapi.DfpObject, length: int) → bytes#

Returns DFP bytes as Python bytes

property model_inports#
property model_outports#
property num_chips#
property num_inports#
property num_models#
property num_outports#
property num_used_inports#
property num_used_outports#
property use_multigroup_lb#
class MxModelInfo#
property in_featuremap_shapes#
property in_featuremap_sizes#
property input_layer_names#
property model_index#
property num_in_featuremaps#
property num_out_featuremaps#
property out_featuremap_shapes#
property out_featuremap_sizes#
property output_layer_names#
property use_model_shape_in#
property use_model_shape_out#
class ShapeVector#
chfirst_shape(self: memryx.runtime.mxapi.ShapeVector) → list[int]#

Returns the tensor shape in channel-first order.

chlast_shape(self: memryx.runtime.mxapi.ShapeVector) → list[int]#

Returns the tensor shape in channel-last order.

model_shape(self: memryx.runtime.mxapi.ShapeVector) → list[int]#

Returns the tensor shape in model order.

model_shape_str(self: memryx.runtime.mxapi.ShapeVector) → str#
mx_shape(self: memryx.runtime.mxapi.ShapeVector) → list[int]#

Returns the tensor shape in MX device order.

mx_shape_str(self: memryx.runtime.mxapi.ShapeVector) → str#
class FeatureMap#
stream_ifmap()#

stream_ifmap in shared mode

stream_ofmap()#

stream_ofmap in shared mode

Benchmarking#

mx_bench(dfp: object, **kwargs) → memryx.runtime.mxapi.MxBenchResult#

Benchmark a DFP, same as the mx_bench CLI, and return an MxBenchResult.

dfp is a path (str or os.PathLike), or the DFP itself as bytes, bytearray or any object with __bytes__ (such as memryx.Dfp).

Keyword arguments are the CLI long options: a value is passed as –name value, True as a flag, a list as a comma-separated value. For example:

result = mxapi.mx_bench(“model.dfp”, frames=500, numstreams=2, power=True, device_ids=[0, 1])

Returns total_fps, power_w (None without power=True) and models: one MxBenchModelResult per benchmarked model (every model unless models=[0, 2] picks some), with its index, fps, stream_fps and latency_ms (one frame at a time with no load, None with no_latency=True).

Only the final results are printed by default; print_results_only=False shows the live FPS table instead, when stdout is a terminal, and quiet=True prints nothing (errors still go to stderr). Ctrl-C ends the run early, like the CLI. Raises ValueError for an invalid option value, RuntimeError if the CLI would exit with an error, and TypeError for an unsupported dfp.

mx_bench_cli(args: list[str]) → int#

Run the mx_bench CLI with these arguments (without the program name) and return its exit code.

exit_code = mxapi.mx_bench_cli([“-d”, “model.dfp”, “–models”, “0”])

Prints exactly what the mx_bench executable prints, including its help for [“-h”].

class MxBenchResult#
property models#
property power_w#
property total_fps#
class MxBenchModelResult#
property fps#
property index#
property latency_ms#
property stream_fps#