diff --git a/validation/tools/compare_raptor_pimcomp.py b/validation/tools/compare_raptor_pimcomp.py index 9782931..7bf5b6f 100644 --- a/validation/tools/compare_raptor_pimcomp.py +++ b/validation/tools/compare_raptor_pimcomp.py @@ -311,7 +311,7 @@ def compile_reference( model_path: Path, work_dir: Path, steps: list[StepRecord], -) -> tuple[Path, Path, Path]: +) -> Path: raptor_dir = work_dir / "reference" runner_dir = work_dir / "runner" build_dir = runner_dir / "build" @@ -323,14 +323,8 @@ def compile_reference( run_logged( "Reference Emit ONNX IR", - [ - str(args.raptor_path), - str(model_path), - "-o", - str(onnx_ir_base), - "--EmitONNXIR", - "--enable-conv-opt-pass=false", - ], + [str(args.raptor_path), str(model_path), "-o", str(onnx_ir_base), "--EmitONNXIR", + "--mlir-elide-elementsattrs-if-larger=16", "--enable-conv-opt-pass=false"], cwd=REPO, timeout_sec=args.timeout_seconds, steps=steps, @@ -343,7 +337,6 @@ def compile_reference( steps=steps, ) network_so = runner_base.with_suffix(".so") - network_mlir = onnx_ir_base.with_suffix(".onnx.mlir") print_step("Generate Runner Source") gen_network_runner(model_path, network_so, args.onnx_include_dir, out=runner_dir / "runner.c", verbose=False) @@ -362,7 +355,7 @@ def compile_reference( timeout_sec=args.timeout_seconds, steps=steps, ) - return network_mlir, network_so, build_dir / "runner" + return build_dir / "runner" def generate_reference_outputs( @@ -390,7 +383,7 @@ def generate_reference_outputs( def compile_raptor_target( - model_mlir: Path, + model_path: Path, out_dir: Path, hardware: dict[str, int], args: argparse.Namespace, @@ -399,7 +392,7 @@ def compile_raptor_target( out_dir.mkdir(parents=True, exist_ok=True) cmd = [ str(args.raptor_path), - str(model_mlir), + str(model_path), "-o", str(out_dir / "model"), "--maccel=PIM", @@ -416,7 +409,7 @@ def compile_raptor_target( raptor_extra_args = ["--pim-emit-json", *args.raptor_extra_arg] try: timings = compile_with_raptor( - model_mlir, + model_path, args.raptor_path, out_dir / "model", hardware["crossbar_size"], @@ -1229,7 +1222,6 @@ def main(): arrays_in_order: list[np.ndarray] = [] runtime_inputs: list[np.ndarray] = [] - network_mlir: Path | None = None runner_path: Path | None = None reference_dir: Path | None = None raptor_pim_dir: Path | None = None @@ -1272,7 +1264,6 @@ def main(): raptor_pass_timings = reused["raptor_pass_timings"] print(f"\n[Reuse Raptor]\n Report: {reuse_report_path}") - expected_network_mlir = out_dir / "reference" / f"{model_path.stem}.onnx.mlir" expected_runner_path = out_dir / "runner" / "build" / "runner" if not reuse_raptor: @@ -1286,11 +1277,8 @@ def main(): steps, ) if reference_compile is not None: - network_mlir, _, runner_path = reference_compile + runner_path = reference_compile else: - if expected_network_mlir.exists(): - network_mlir = expected_network_mlir - print(f"\n[Continue] Reusing partial ONNX MLIR: {network_mlir}") if expected_runner_path.exists(): runner_path = expected_runner_path print(f"\n[Continue] Reusing partial runner: {runner_path}") @@ -1317,12 +1305,12 @@ def main(): "Reference outputs were skipped because the native runner or model inputs are not available.", ) - if not reuse_raptor and network_mlir is not None and network_mlir.exists() and hardware["core_count"] > 0: + if not reuse_raptor and model_path.exists() and hardware["core_count"] > 0: compiled_raptor = try_stage( failures, "Compile Raptor PIM", compile_raptor_target, - network_mlir, + model_path, out_dir / "raptor", hardware, args, @@ -1334,7 +1322,7 @@ def main(): record_failure( failures, "Skip Raptor PIM compile", - "Raptor PIM compile was skipped because the ONNX MLIR or hardware configuration is not available.", + "Raptor PIM compile was skipped because the ONNX model or hardware configuration is not available.", ) if not reuse_raptor and raptor_pim_dir is not None: diff --git a/validation/validate_one.py b/validation/validate_one.py index 9f663c6..74535ad 100644 --- a/validation/validate_one.py +++ b/validation/validate_one.py @@ -228,7 +228,8 @@ def compile_onnx_network(network_onnx_path, raptor_path, raptor_dir, runner_dir, stem = network_onnx_path.stem onnx_ir_base = raptor_dir / stem runner_base = runner_dir / stem - run_command([raptor_path, network_onnx_path, "-o", onnx_ir_base, "--EmitONNXIR"], + run_command([raptor_path, network_onnx_path, "-o", onnx_ir_base, "--EmitONNXIR", + "--mlir-elide-elementsattrs-if-larger=16"], reporter=reporter, timeout_sec=timeout_sec) run_command([raptor_path, network_onnx_path, "-o", runner_base], reporter=reporter, timeout_sec=timeout_sec) network_so_path = runner_base.with_suffix(".so")