onnx_light.tools.kernel_baseline#

Deterministic benchmark corpus and cross-machine baseline report (Step E).

See Kernel parallelization and tuning sequence. This module runs a fixed, representative shape corpus for a small set of native onnx-light kernels under an explicit serial CPU policy and the default session-thread policy, and combines the measurements with the Step D onnx_light.tools.kernel_inventory coverage state into one machine-readable report.

The tool never invokes onnxruntime and never persists kernel tuning values: only onnx_light.kernel_tuning.kernel_tuning_parameters() (a read-only inspection call) and ordinary onnx_light.onnx_py._onnxpykernels.runtime.RuntimeSession runs are used, so it can run as often as needed without disturbing the tuning cache.

onnx_light.tools.kernel_baseline.get_cpu_descriptor() dict[str, Any]#

Returns a best-effort, portable CPU descriptor for the local machine.

Missing information is omitted rather than replaced by an invented value.

Returns:

A mapping with at least architecture and logical_cores.

onnx_light.tools.kernel_baseline.run_benchmark_corpus(*, cases: tuple[dict[str, Any], ...] | None = None, cpu_policies: tuple[tuple[str, int], ...] | None = None, repeat: int = 5, warmup: int = 2, seed: int = 0, collect_diagnostics: bool = True) list[dict[str, Any]]#

Runs every (case, shape, cpu policy) combination in the corpus.

Parameters:
  • cases – Benchmark cases; defaults to BENCHMARK_CORPUS.

  • cpu_policies(label, num_threads) pairs; defaults to CPU_POLICIES.

Returns:

A flat list of result rows; see run_kernel_baseline_report() for the combined report schema.

onnx_light.tools.kernel_baseline.run_kernel_baseline_report(*, cases: tuple[dict[str, Any], ...] | None = None, cpu_policies: tuple[tuple[str, int], ...] | None = None, repeat: int = 5, warmup: int = 2, seed: int = 0, collect_diagnostics: bool = True) dict[str, Any]#

Produces the combined Step D + Step E machine-readable report.

This is the single entry point behind python -m onnx_light kernel-baseline: it does not modify the kernel tuning cache and does not invoke onnxruntime, so only native onnx-light kernel execution enters the report.

Parameters:
  • cases – Benchmark cases; defaults to BENCHMARK_CORPUS.

  • cpu_policies(label, num_threads) pairs; defaults to CPU_POLICIES.

Returns:

A mapping with cpu_descriptor, inventory (Step D rows) and benchmarks (Step E rows).