benchdnn_helper#
Helpers for invoking benchdnn correctness/performance runs and parsing output.
Functions
|
Run benchdnn in correctness mode and report pass/fail. |
|
Run benchdnn in performance mode and return measured runtime. |
|
Detect correctness success from benchdnn stdout. |
|
Extract |
- kernelfoundry.eval_pipeline.utils.benchdnn_helper.parse_benchdnn_correctness_check(stdout: str) bool[source]#
Detect correctness success from benchdnn stdout.
This parser looks for benchdnn result lines in the REPRO format:
case_num:status[ ... ] __REPRO: ....Expected input includes exactly one REPRO line.
- Parameters:
stdout – Raw stdout text produced by benchdnn in correctness mode.
- Returns:
Truewhen the single REPRO line hasPASSEDstatus, otherwiseFalse.- Raises:
ValueError – If stdout contains zero or multiple REPRO lines, or if the REPRO line does not match the expected
case_num:statusprefix format.
- kernelfoundry.eval_pipeline.utils.benchdnn_helper.parse_benchdnn_perf_stats(stdout: str) dict[source]#
Extract
avg_timefrom benchdnn performance stdout.Expected input includes exactly two CSV-like
perf,lines: one header row and one value row.- Parameters:
stdout – Raw stdout text produced by benchdnn in performance mode.
- Returns:
A dictionary containing the parsed
avg_timevalue asfloat.- Raises:
ValueError – If expected perf rows are missing, malformed, missing
avg_time, or contain a non-numericavg_timevalue.
- kernelfoundry.eval_pipeline.utils.benchdnn_helper.check_correctness_benchdnn(benchdnn_bin: str, driver: str, test_shape: str | None = None, ld_preload: str | None = None, use_custom_kernel: bool = False, verbosity_level: int = 0, log_stdout: bool = False) bool[source]#
Run benchdnn in correctness mode and report pass/fail.
- Parameters:
benchdnn_bin – Path to the benchdnn executable.
driver – benchdnn driver name (for example,
--matmul).test_shape – Shape string for the benchdnn CLI call.
ld_preload – Value for
LD_PRELOADpointing to custom kernel .so.use_custom_kernel – Whether to set
DNNL_USE_CUSTOM_KERNEL=1.verbosity_level – Value written to
ONEDNN_VERBOSE.log_stdout – Whether to emit benchdnn stdout through
logging.info.
- Returns:
Truewhen benchdnn stdout indicates a pass, otherwiseFalse.- Raises:
ValueError – If
test_shapeis empty.RuntimeError – If benchdnn exits with a non-zero return code.
- kernelfoundry.eval_pipeline.utils.benchdnn_helper.measure_runtime_benchdnn(benchdnn_bin: str, driver: str, test_shape: str | None = None, ld_preload: str | None = None, use_custom_kernel: bool = False, verbosity_level: int = 0, log_stdout: bool = False, output: list[float] | None = None) list[float][source]#
Run benchdnn in performance mode and return measured runtime.
- Parameters:
benchdnn_bin – Path to the benchdnn executable.
driver – benchdnn driver name (for example,
--matmul).test_shape – Shape string for the benchdnn CLI call.
ld_preload – Value for
LD_PRELOADpointing to custom kernel .so.use_custom_kernel – Whether to set
DNNL_USE_CUSTOM_KERNEL=1.verbosity_level – Value written to
ONEDNN_VERBOSE.log_stdout – Whether to emit benchdnn stdout through
logging.info.output – Optional list that, when provided, is extended in-place with the returned runtime values.
- Returns:
A single-item list containing
avg_timeparsed from benchdnn output.- Raises:
ValueError – If
test_shapeis empty or perf output parsing fails.RuntimeError – If benchdnn exits with a non-zero return code.