add validation artifacts cleanup
This commit is contained in:
@@ -5,19 +5,21 @@ import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from colorama import Style, Fore
|
||||
from validate_one import ProgressReporter, validate_network
|
||||
from validate_one import ProgressReporter, clean_workspace_artifacts, validate_network
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser(description="Validate all ONNX operations under the operations/ directory.")
|
||||
ap.add_argument("--raptor-path", required=True, help="Path to the Raptor compiler binary.")
|
||||
ap.add_argument("--onnx-include-dir", required=True, help="Path to OnnxMlirRuntime include directory.")
|
||||
ap.add_argument("--raptor-path", help="Path to the Raptor compiler binary.")
|
||||
ap.add_argument("--onnx-include-dir", help="Path to OnnxMlirRuntime include directory.")
|
||||
ap.add_argument("--operations-dir", default=None, help="Root of the operations tree (default: operations).")
|
||||
ap.add_argument("--simulator-dir", default=None,
|
||||
help="Path to pim-simulator crate root (default: auto-detected relative to script).")
|
||||
ap.add_argument("--threshold", type=float, default=1e-3, help="Max allowed diff per output element.")
|
||||
ap.add_argument("--crossbar-size", type=int, default=64)
|
||||
ap.add_argument("--crossbar-count", type=int, default=8)
|
||||
ap.add_argument("--clean", action="store_true",
|
||||
help="Remove generated validation artifacts under each model workspace and exit.")
|
||||
a = ap.parse_args()
|
||||
|
||||
script_dir = Path(__file__).parent.resolve()
|
||||
@@ -35,6 +37,21 @@ def main():
|
||||
print(Fore.YELLOW + f"No .onnx files found under {operations_dir}" + Style.RESET_ALL)
|
||||
sys.exit(1)
|
||||
|
||||
if a.clean:
|
||||
removed_count = 0
|
||||
for onnx_path in onnx_files:
|
||||
removed_count += len(clean_workspace_artifacts(onnx_path.parent, onnx_path.stem))
|
||||
print(Style.BRIGHT + f"Removed {removed_count} generated artifact path(s)." + Style.RESET_ALL)
|
||||
sys.exit(0)
|
||||
|
||||
missing_args = []
|
||||
if not a.raptor_path:
|
||||
missing_args.append("--raptor-path")
|
||||
if not a.onnx_include_dir:
|
||||
missing_args.append("--onnx-include-dir")
|
||||
if missing_args:
|
||||
ap.error("the following arguments are required unless --clean is used: " + ", ".join(missing_args))
|
||||
|
||||
print(Style.BRIGHT + f"Found {len(onnx_files)} ONNX file(s) to validate." + Style.RESET_ALL)
|
||||
print(f"Operations root: {operations_dir}")
|
||||
print("=" * 72)
|
||||
|
||||
Reference in New Issue
Block a user