elide big constants in onnx mlir dump
Validate Operations / validate-operations (push) Waiting to run
Validate Operations / validate-operations (push) Waiting to run
This commit is contained in:
@@ -294,7 +294,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"
|
||||||
@@ -306,7 +306,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), str(model_path), "-o", str(onnx_ir_base), "--EmitONNXIR",
|
||||||
|
"--mlir-elide-elementsattrs-if-larger=16"],
|
||||||
cwd=REPO,
|
cwd=REPO,
|
||||||
timeout_sec=args.timeout_seconds,
|
timeout_sec=args.timeout_seconds,
|
||||||
steps=steps,
|
steps=steps,
|
||||||
@@ -319,7 +320,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)
|
||||||
@@ -338,7 +338,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(
|
||||||
@@ -366,7 +366,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,
|
||||||
@@ -375,7 +375,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",
|
||||||
@@ -392,7 +392,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"],
|
||||||
@@ -1180,7 +1180,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
|
||||||
@@ -1205,7 +1204,6 @@ def main():
|
|||||||
if model_io is not None:
|
if model_io is not None:
|
||||||
inputs_desc, outputs_desc, arrays_in_order, runtime_inputs = model_io
|
inputs_desc, outputs_desc, arrays_in_order, runtime_inputs = model_io
|
||||||
|
|
||||||
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"
|
||||||
|
|
||||||
reference_compile = try_stage(
|
reference_compile = try_stage(
|
||||||
@@ -1218,11 +1216,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}")
|
||||||
@@ -1249,12 +1244,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 network_mlir is not None and network_mlir.exists() and hardware["core_count"] > 0:
|
if 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,
|
||||||
@@ -1266,7 +1261,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 raptor_pim_dir is not None:
|
if 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