even better more structured throughput scheduling
Validate Operations / validate-operations (push) Has been cancelled

plot adjustments
validation adjustments
This commit is contained in:
NiccoloN
2026-10-27 17:46:46 +01:00
parent 49d6fb42cf
commit a77edafcbf
46 changed files with 3265 additions and 1043 deletions
+19 -18
View File
@@ -24,6 +24,7 @@ from .onnx_utils import (
from .raptor import compile_with_raptor
from .pimsim_nn import export_raptor_pimsim_artifact, parse_pimsim_nn_metrics, read_raptor_instruction_count
from .subprocess_utils import run_command_with_reporter
from .output_comparison import compare_output_arrays
STAGE_TITLES = (
"Compile ONNX",
@@ -465,34 +466,35 @@ def parse_pim_simulator_outputs(output_bin_path, outputs_descriptor):
def validate_outputs(sim_arrays, runner_out_dir, outputs_descriptor, threshold, rtol, verbose):
if len(sim_arrays) != len(outputs_descriptor):
raise ValueError("simulator output count differs from the model output count")
all_passed = True
rows = []
for sim_array, (oi, name, _, shape) in zip(sim_arrays, outputs_descriptor):
for sim_array, (oi, name, elem_type, shape) in zip(sim_arrays, outputs_descriptor):
csv_name = f"output{oi}_{sanitize_output_name(name)}.csv"
runner_array = np.loadtxt(runner_out_dir / csv_name, delimiter=',', dtype=np.float32).reshape(shape)
sim_array64 = sim_array.astype(np.float64)
runner_array64 = runner_array.astype(np.float64)
abs_diff = np.abs(sim_array64 - runner_array64)
allowed_diff = threshold + rtol * np.abs(runner_array64)
max_diff = float(np.max(abs_diff))
passed = bool(np.all(abs_diff <= allowed_diff))
rows.append((name, f"{max_diff:.6e}", passed))
runner_array = np.loadtxt(runner_out_dir / csv_name, delimiter=',', dtype=_ONNX_TO_NP[elem_type]).reshape(shape)
comparison = compare_output_arrays(sim_array, runner_array, atol=threshold, rtol=rtol)
passed = comparison.passed
relative = comparison.relative_l2_error
rows.append((name, f"{comparison.max_abs_diff:.6e}",
f"{relative:.6e}" if relative is not None else "N/A", passed))
if not passed:
all_passed = False
name_width = max(len("Output"), *(len(name) for name, _, _ in rows))
diff_width = max(len("Max diff"), *(len(diff) for _, diff, _ in rows))
name_width = max(len("Output"), *(len(name) for name, _, _, _ in rows))
diff_width = max(len("Max diff"), *(len(diff) for _, diff, _, _ in rows))
relative_width = max(len("Relative L2"), *(len(relative) for _, _, relative, _ in rows))
result_width = len("Result")
separator = f" +-{'-' * name_width}-+-{'-' * diff_width}-+-{'-' * result_width}-+"
separator = f" +-{'-' * name_width}-+-{'-' * diff_width}-+-{'-' * relative_width}-+-{'-' * result_width}-+"
if verbose or not all_passed:
print(separator)
print(f" | {'Output'.ljust(name_width)} | {'Max diff'.ljust(diff_width)} | {'Result'} |")
print(f" | {'Output'.ljust(name_width)} | {'Max diff'.ljust(diff_width)} | {'Relative L2'.ljust(relative_width)} | {'Result'} |")
print(separator)
for name, diff_text, passed in rows:
for name, diff_text, relative, passed in rows:
status_text = ("PASS" if passed else "FAIL").ljust(result_width)
status = Fore.GREEN + status_text + Style.RESET_ALL if passed else Fore.RED + status_text + Style.RESET_ALL
print(f" | {name.ljust(name_width)} | {diff_text.ljust(diff_width)} | {status} |")
print(f" | {name.ljust(name_width)} | {diff_text.ljust(diff_width)} | {relative.ljust(relative_width)} | {status} |")
print(separator)
return all_passed
@@ -577,10 +579,9 @@ def validate_execution(
f"Latency: {state['metrics']['latency_ms']:.2f} ms"
if name == "latency" else
f"Throughput: {state['metrics']['throughput']:.2f} samples/s")
energy_unit = "pJ" if name == "latency" else "pJ/it"
print_info(
reporter, f"{metric}, Power: {state['metrics']['average_power_mw']:.2f} mW, "
f"Energy: {state['metrics']['average_energy_pj']:.2f} {energy_unit}")
reporter, f"{metric}, Average power: {state['metrics']['average_power_mw']:.2f} mW, "
f"Energy per inference: {state['metrics']['average_energy_pj']:.2f} pJ/inference")
except PimSimUnsupportedError as exc:
state["pimsim_status"] = PIMSIM_UNSUPPORTED
print_info(reporter, str(exc))