Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved

"""Run VAIML tests on a PetaLinux board with the Detailed Profile Report flow (on by default;
--no-detailed-profiling turns it off).

Expand All @@ -15,8 +18,8 @@

Setup, done once (the pip3 commands are skipped with --skip-setup):
pip3 config set global.trusted-host "..."; pip3 install torch==2.5.1 onnx pandas torchvision==0.20.1 ...
LD_LIBRARY_PATH, XRT_AIARM, XLNX_ENABLE_CACHE, ENABLE_ML_DEBUG, QEMU_TEST,
DEBUG_VAIML_PARTITION and FLEXMLRT_LOG_LEVEL are set for every run.
LD_LIBRARY_PATH, XRT_AIARM, XLNX_ENABLE_CACHE, ENABLE_ML_DEBUG, QEMU_TEST and
DEBUG_VAIML_PARTITION are set for every run.
Then, also once and even with --skip-setup,
pip3 list | grep -iE 'flexmlrt|voe|onnxruntime[-_]vitisai'
checks the VAI packages (pip may list onnxruntime-vitisai as onnxruntime_vitisai).
Expand All @@ -29,8 +32,10 @@
For each test, from its own folder, the overlay is reloaded first:
fpgautil -R
fpgautil -b ./overlay/x_plus_ml.pdi -o ./overlay/x_plus_ml.dtbo
If <test>/overlay/ lacks either file, or either command fails, the test is an
ERROR and none of its runs are done.
If <test>/overlay/ or either file is missing, a warning is printed, fpgautil is
not run and the test's runs still go ahead. If fpgautil -R fails, a warning is
printed and fpgautil -b still runs. If fpgautil -b fails, the test is an ERROR
and none of its runs are done.

Each test is then run once from its own folder:
python ve2.py --input_model onnx_model/<model>.onnx --analyzer_profiling True
Expand Down Expand Up @@ -124,7 +129,7 @@
FPGA_LOG = 'fpgautil.log'
LD_PATHS = ('/usr/lib/python3.12/site-packages/flexmlrt/lib/', '/usr/lib/python3.12/site-packages/voe/lib/')
ENV = (('XRT_AIARM', 'true'), ('XLNX_ENABLE_CACHE', '0'), ('ENABLE_ML_DEBUG', '0'), ('QEMU_TEST', '0'),
('DEBUG_VAIML_PARTITION', '2'), ('FLEXMLRT_LOG_LEVEL', 'debug'))
('DEBUG_VAIML_PARTITION', '2'))
PROFILE_RUNS = (
('A', 'detailed_core_shim_read_ch_0',
{'interface_tile': 'detailed_ddr_read_bandwidth:0', 'aie_tile': 'compute_io_bound'}),
Expand Down Expand Up @@ -658,15 +663,25 @@ def ensure_vai_packages(test_path, test_dirs, single, dry_run, timeout):
return None


def missing_overlay(test_dir):
"""Return a description of what is missing from <test>/overlay/, or None if OVERLAY_FILES are all there."""
overlay_dir = os.path.dirname(OVERLAY_FILES[0])
if not os.path.isdir(os.path.join(test_dir, overlay_dir)):
return '%s/ not found' % overlay_dir
missing = [f for f in OVERLAY_FILES if not os.path.isfile(os.path.join(test_dir, f))]
return '%s not found' % ' and '.join(missing) if missing else None


def load_overlay(test_dir, timeout):
"""Run FPGA_CMDS from test_dir, logged to <test>/fpgautil.log. Return an error or None."""
"""Run FPGA_CMDS from test_dir, logged to <test>/fpgautil.log.

Return (warning or None, error or None): fpgautil -R failing is a warning, fpgautil -b failing is an error.
"""
log_path = os.path.join(test_dir, FPGA_LOG)
open(log_path, 'w').close()
for cmd in FPGA_CMDS:
err = run_logged(cmd, test_dir, log_path, timeout)
if err:
return err
return None
reset_cmd, load_cmd = FPGA_CMDS
warning = run_logged(reset_cmd, test_dir, log_path, timeout)
return warning, run_logged(load_cmd, test_dir, log_path, timeout)


def run_one_test(name, test_dir, model, tag, test_runner, profiling, args):
Expand All @@ -691,22 +706,25 @@ def run_one_test(name, test_dir, model, tag, test_runner, profiling, args):
return row
if ops:
cmd += ['--vaiml_custom_ops', ops]
missing = [f for f in OVERLAY_FILES if not os.path.isfile(os.path.join(test_dir, f))]
if missing:
row['status'] = 'ERROR (%s not found)' % ' and '.join(missing)
print('ERROR %s: %s not found; no runs done' % (tag, ' and '.join(missing)))
return row
overlay_missing = missing_overlay(test_dir)
if overlay_missing:
msg = '%s; fpgautil skipped' % overlay_missing
row['note'] = msg
print('WARNING %s: %s' % (tag, msg))
if profiling and not control_instrumentation_found(test_dir, cfg):
row['note'] = CI_WARNING
row['note'] = '; '.join(n for n in (row.get('note'), CI_WARNING) if n)
print('WARNING %s: %s' % (tag, CI_WARNING))
base_cfg = with_control_instrumentation(cfg) if profiling else None
if profiling:
row['profile'] = 'on'

if args.dry_run:
print(' cwd: %s' % test_dir)
for fcmd in FPGA_CMDS:
print(' %s >> %s' % (subprocess.list2cmdline(fcmd), FPGA_LOG))
if overlay_missing:
print(' (fpgautil skipped: %s)' % overlay_missing)
else:
for fcmd in FPGA_CMDS:
print(' %s >> %s' % (subprocess.list2cmdline(fcmd), FPGA_LOG))
print(' %s > %s' % (subprocess.list2cmdline(cmd), BASE_LOG))
if has_control_instrumentation(cfg):
print(' (Base Run: control_instrumentation removed from %s; restored only if the Base Run '
Expand All @@ -727,14 +745,19 @@ def run_one_test(name, test_dir, model, tag, test_runner, profiling, args):
row['status'] = 'DRY_RUN'
return row

print('%s: Reloading Overlay (fpgautil -R, fpgautil -b) ...' % tag)
sys.stdout.flush()
err = load_overlay(test_dir, args.timeout)
if err:
row['status'] = 'ERROR (%s)' % err
row.pop('profile', None)
print('ERROR %s: %s; no runs done' % (tag, err))
return row
if not overlay_missing:
print('%s: Reloading Overlay (fpgautil -R, fpgautil -b) ...' % tag)
sys.stdout.flush()
warning, err = load_overlay(test_dir, args.timeout)
if warning:
msg = '%s; continuing' % warning
row['note'] = '; '.join(n for n in (row.get('note'), msg) if n)
print('WARNING %s: %s' % (tag, msg))
if err:
row['status'] = 'ERROR (%s)' % err
row.pop('profile', None)
print('ERROR %s: %s; no runs done' % (tag, err))
return row
print('%s: Running Inference ...' % tag)
sys.stdout.flush()
status, rc, secs, note = base_run(cmd, test_dir, cfg, args.timeout, tag)
Expand Down
Loading