validate
This commit is contained in:
@@ -311,7 +311,7 @@ def compile_reference(
|
|||||||
model_path: Path,
|
model_path: Path,
|
||||||
work_dir: Path,
|
work_dir: Path,
|
||||||
steps: list[StepRecord],
|
steps: list[StepRecord],
|
||||||
) -> tuple[Path, Path, Path]:
|
) -> Path:
|
||||||
raptor_dir = work_dir / "reference"
|
raptor_dir = work_dir / "reference"
|
||||||
runner_dir = work_dir / "runner"
|
runner_dir = work_dir / "runner"
|
||||||
build_dir = runner_dir / "build"
|
build_dir = runner_dir / "build"
|
||||||
@@ -323,14 +323,8 @@ def compile_reference(
|
|||||||
|
|
||||||
run_logged(
|
run_logged(
|
||||||
"Reference Emit ONNX IR",
|
"Reference Emit ONNX IR",
|
||||||
[
|
[str(args.raptor_path), str(model_path), "-o", str(onnx_ir_base), "--EmitONNXIR",
|
||||||
str(args.raptor_path),
|
"--mlir-elide-elementsattrs-if-larger=16", "--enable-conv-opt-pass=false"],
|
||||||
str(model_path),
|
|
||||||
"-o",
|
|
||||||
str(onnx_ir_base),
|
|
||||||
"--EmitONNXIR",
|
|
||||||
"--enable-conv-opt-pass=false",
|
|
||||||
],
|
|
||||||
cwd=REPO,
|
cwd=REPO,
|
||||||
timeout_sec=args.timeout_seconds,
|
timeout_sec=args.timeout_seconds,
|
||||||
steps=steps,
|
steps=steps,
|
||||||
@@ -343,7 +337,6 @@ def compile_reference(
|
|||||||
steps=steps,
|
steps=steps,
|
||||||
)
|
)
|
||||||
network_so = runner_base.with_suffix(".so")
|
network_so = runner_base.with_suffix(".so")
|
||||||
network_mlir = onnx_ir_base.with_suffix(".onnx.mlir")
|
|
||||||
|
|
||||||
print_step("Generate Runner Source")
|
print_step("Generate Runner Source")
|
||||||
gen_network_runner(model_path, network_so, args.onnx_include_dir, out=runner_dir / "runner.c", verbose=False)
|
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,
|
timeout_sec=args.timeout_seconds,
|
||||||
steps=steps,
|
steps=steps,
|
||||||
)
|
)
|
||||||
return network_mlir, network_so, build_dir / "runner"
|
return build_dir / "runner"
|
||||||
|
|
||||||
|
|
||||||
def generate_reference_outputs(
|
def generate_reference_outputs(
|
||||||
@@ -390,7 +383,7 @@ def generate_reference_outputs(
|
|||||||
|
|
||||||
|
|
||||||
def compile_raptor_target(
|
def compile_raptor_target(
|
||||||
model_mlir: Path,
|
model_path: Path,
|
||||||
out_dir: Path,
|
out_dir: Path,
|
||||||
hardware: dict[str, int],
|
hardware: dict[str, int],
|
||||||
args: argparse.Namespace,
|
args: argparse.Namespace,
|
||||||
@@ -399,7 +392,7 @@ def compile_raptor_target(
|
|||||||
out_dir.mkdir(parents=True, exist_ok=True)
|
out_dir.mkdir(parents=True, exist_ok=True)
|
||||||
cmd = [
|
cmd = [
|
||||||
str(args.raptor_path),
|
str(args.raptor_path),
|
||||||
str(model_mlir),
|
str(model_path),
|
||||||
"-o",
|
"-o",
|
||||||
str(out_dir / "model"),
|
str(out_dir / "model"),
|
||||||
"--maccel=PIM",
|
"--maccel=PIM",
|
||||||
@@ -416,7 +409,7 @@ def compile_raptor_target(
|
|||||||
raptor_extra_args = ["--pim-emit-json", *args.raptor_extra_arg]
|
raptor_extra_args = ["--pim-emit-json", *args.raptor_extra_arg]
|
||||||
try:
|
try:
|
||||||
timings = compile_with_raptor(
|
timings = compile_with_raptor(
|
||||||
model_mlir,
|
model_path,
|
||||||
args.raptor_path,
|
args.raptor_path,
|
||||||
out_dir / "model",
|
out_dir / "model",
|
||||||
hardware["crossbar_size"],
|
hardware["crossbar_size"],
|
||||||
@@ -1229,7 +1222,6 @@ def main():
|
|||||||
arrays_in_order: list[np.ndarray] = []
|
arrays_in_order: list[np.ndarray] = []
|
||||||
runtime_inputs: list[np.ndarray] = []
|
runtime_inputs: list[np.ndarray] = []
|
||||||
|
|
||||||
network_mlir: Path | None = None
|
|
||||||
runner_path: Path | None = None
|
runner_path: Path | None = None
|
||||||
reference_dir: Path | None = None
|
reference_dir: Path | None = None
|
||||||
raptor_pim_dir: Path | None = None
|
raptor_pim_dir: Path | None = None
|
||||||
@@ -1272,7 +1264,6 @@ def main():
|
|||||||
raptor_pass_timings = reused["raptor_pass_timings"]
|
raptor_pass_timings = reused["raptor_pass_timings"]
|
||||||
print(f"\n[Reuse Raptor]\n Report: {reuse_report_path}")
|
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"
|
expected_runner_path = out_dir / "runner" / "build" / "runner"
|
||||||
|
|
||||||
if not reuse_raptor:
|
if not reuse_raptor:
|
||||||
@@ -1286,11 +1277,8 @@ def main():
|
|||||||
steps,
|
steps,
|
||||||
)
|
)
|
||||||
if reference_compile is not None:
|
if reference_compile is not None:
|
||||||
network_mlir, _, runner_path = reference_compile
|
runner_path = reference_compile
|
||||||
else:
|
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():
|
if expected_runner_path.exists():
|
||||||
runner_path = expected_runner_path
|
runner_path = expected_runner_path
|
||||||
print(f"\n[Continue] Reusing partial runner: {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.",
|
"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(
|
compiled_raptor = try_stage(
|
||||||
failures,
|
failures,
|
||||||
"Compile Raptor PIM",
|
"Compile Raptor PIM",
|
||||||
compile_raptor_target,
|
compile_raptor_target,
|
||||||
network_mlir,
|
model_path,
|
||||||
out_dir / "raptor",
|
out_dir / "raptor",
|
||||||
hardware,
|
hardware,
|
||||||
args,
|
args,
|
||||||
@@ -1334,7 +1322,7 @@ def main():
|
|||||||
record_failure(
|
record_failure(
|
||||||
failures,
|
failures,
|
||||||
"Skip Raptor PIM compile",
|
"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:
|
if not reuse_raptor and raptor_pim_dir is not None:
|
||||||
|
|||||||
@@ -228,7 +228,8 @@ def compile_onnx_network(network_onnx_path, raptor_path, raptor_dir, runner_dir,
|
|||||||
stem = network_onnx_path.stem
|
stem = network_onnx_path.stem
|
||||||
onnx_ir_base = raptor_dir / stem
|
onnx_ir_base = raptor_dir / stem
|
||||||
runner_base = runner_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)
|
reporter=reporter, timeout_sec=timeout_sec)
|
||||||
run_command([raptor_path, network_onnx_path, "-o", runner_base], 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")
|
network_so_path = runner_base.with_suffix(".so")
|
||||||
|
|||||||
Reference in New Issue
Block a user