Python Benchmark#

Note

The Benchmark API provides a simple way to characterize the neural network model performance on the MX3 chips. For integration, it’s advised to use the Accelerator API.

class Benchmark(verbose=0, dfp: str | Path = 'model.dfp', use_model_shape=False, device_ids=[0], local_mode=True, manager_addr='/run/mxa_manager/', manager_port=10000, scheduler_options=SchedulerOptions(max_queue_size=100, driver_depth=32, is_latency_sensitive=False, model_types=[], op_freq=0, auto_upclocking_enabled=False, upclock_power_limit_mw=11500, upclock_check_fps_saturation=False, upclock_sample_interval_ms=50, upclock_num_samples=6), **kwargs)#

MemryX Benchmark.

The interface to the MemryX Benchmark.

Each run calls mxapi.mx_bench, the C++ benchmark behind the mx_bench CLI, on the MXA(s) connected via PCIe/USB. Nothing is printed; the numbers are returned. Each run opens and releases the accelerator itself, so there is nothing to close afterwards.

Parameters:
verboseint

Unused, kept for compatibility.

dfpstring or pathlib.Path or Dfp

Path to dfp or a Dfp object

Examples

from memryx import Benchmark

# Run inference with 1000 frames of random data
bench = Benchmark(dfp='mobilenet.dfp')
latency, fps = bench.run(frames=1000)
print("Latency {:.2f} ms, FPS {:.2f}".format(latency, fps))
run(frames=500, model_idx=0)#

Benchmark one model of the DFP with random data.

Parameters:
framesint

Number of frames to run for the FPS measurement (defaults to 500).

Warning

Having too few frames may give unreliable results. Try to use a number that will cause your model to run for at least a few seconds.

model_idxint

The model of the DFP to benchmark.

Returns:
latency, fpsfloat, float

Latency is in ms: one frame at a time, 1 warm-up then the mean of 10 runs, so frames is not used for it. FPS has the frames pipelined on the accelerator.

Examples

bench = Benchmark(dfp='mobilenet.dfp')
latency, fps = bench.run(frames=1000, model_idx=0)