Files
retroSoC/scripts/setup_apu_kws_reference.py
T
maksyuki 15f4dd555c feat: add KWS engine and related tests for APU-P7
- Implemented the KWS engine in the RTL and added necessary components including KWS SRAM client and model loader.
- Enhanced the APU ring scheduler testbench to validate KWS descriptors.
- Introduced new Python tests for KWS functionality, including model import validation, inference checks, and error handling for mutated models.
- Updated existing tests to include KWS components and ensure proper integration within the APU architecture.
- Refactored code for clarity and consistency, including adjustments to signal handling and memory management in test cases.
2026-09-12 22:11:49 +08:00

50 lines
1.8 KiB
Python

"""Validate the locked APU-P7 KWS reference inputs without network access."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
REQUIRED_SOURCES = {
"apu_mlperf_tiny": "4addd0fa08d216e20637637874e084895f289da4",
"apu_kws_mfcc": "cf7c2f2634608a7c0ea7458ab7cb3379f2863424",
"apu_tfds": "8997c4140cd4fc145f0693787b1da78691930459",
"apu_tensorflow": "fcc4b966f1265f466e82617020af93670141b009",
"apu_gemmlowp": "fda83bdc38b118cc6b56753bd540caa49e570745",
}
REQUIRED_ARCHIVE = {
"apu_kws_pcm": "cc2a00c1147c2254e9be3fa0f779d8c17421dc349b86366567a8edfa9acd51df"
}
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--lock", type=Path, required=True)
parser.add_argument("--output-dir", type=Path, required=True)
args = parser.parse_args()
lock = json.loads(args.lock.read_text(encoding="utf-8"))
sources = lock.get("sources", {})
archives = lock.get("archives", {})
for name, revision in REQUIRED_SOURCES.items():
if sources.get(name, {}).get("revision") != revision:
raise SystemExit(f"missing or stale locked source: {name}")
for name, checksum in REQUIRED_ARCHIVE.items():
if archives.get(name, {}).get("sha256") != checksum:
raise SystemExit(f"missing or stale locked archive: {name}")
args.output_dir.mkdir(parents=True, exist_ok=True)
manifest = args.output_dir / "provenance.json"
manifest.write_text(
json.dumps(
{"sources": REQUIRED_SOURCES, "archives": REQUIRED_ARCHIVE}, indent=2, sort_keys=True
)
+ "\n",
encoding="utf-8",
)
print(f"APU-P7 locked references validated: {manifest}")
return 0
if __name__ == "__main__":
raise SystemExit(main())