onnx_light.doc#
- class onnx_light.doc.InferenceCaseReport(name: str, model_str: str, error: str | None, comparisons: list[ValueComparison] = <factory>)#
Shape-inference outcome for one
"inference"-tagged test case.- comparisons: list[ValueComparison]#
One
ValueComparisonper input, intermediate (value_info) and output value of the model. Empty whenerroris set.
- error: str | None#
Error message raised by
infer_shapes_model(), orNonewhen shape inference succeeded.
- model_str: str#
Compact text rendering of the original model (with its expected
value_infoannotations), produced bypretty_onnx().
- class onnx_light.doc.InferenceCoverageReport(cases: list[InferenceCaseReport] = <factory>)#
Aggregates
InferenceCaseReportfor every collected case.
- class onnx_light.doc.ValueComparison(name: str, role: str, expected: ValueShape | None, computed: ValueShape | None)#
Per-value comparison of expected vs computed shape.
- computed: ValueShape | None#
Shape produced by
infer_shapes_model(), orNonewhen shape inference produced no entry for that value.
- expected: ValueShape | None#
Shape recorded in the original test model, or
Nonewhen the value has no expected shape (for instance an intermediate without avalue_infoentry).
- property match: bool#
Returns whether
expectedandcomputedagree.A value with no expected shape (
expected is None) is considered to match by convention so that intermediate values without avalue_infoentry do not flag the case as failing. Otherwise both the element type and the shape must be equal.
- class onnx_light.doc.ValueShape(elem_type: int | None, shape: list[int | str | None] | None)#
Shape / element type of a single tensor value (input, intermediate or output) in a backend test model.
A shape entry is
Nonewhen the correspondingValueInfoProtohas no type set (so the value is opaque to shape inference). Dimensions are encoded as eitherint(dim_value),str(dim_param) orNone(unknown dimension).
- onnx_light.doc.compute_inference_coverage() InferenceCoverageReport#
Computes the shape-inference report for every
"inference"case.For every case, the model is deep-cloned, its
graph.value_infois cleared, andinfer_shapes_model()(fromonnx_shapes) is run on the clone. The report contrasts the expected shapes from the original model with the computed shapes from the inferred clone.
- onnx_light.doc.find_standalone_executable(executable_name: str, relative_candidates: list[Path | str], script_file: str | None, windows_build_configs: tuple[str, ...] | None = None, reason_out: list[str] | None = None) str | None#
Locates a standalone executable built from repository examples.
- Parameters:
executable_name – Name used for PATH lookup fallback.
relative_candidates – Candidate executable paths relative to repository root.
script_file – Path to the calling script file used to locate repository root. The repository root is assumed to be three parent directories above this path.
windows_build_configs – Optional Windows build configuration folder names.
reason_out – Optional list that, when provided, receives a human-readable string describing why the executable could not be located when this function returns
None. Useful for surfacing the cause (CI mode, missing build artifacts, not onPATH) in user-facing diagnostics.
- Returns:
The discovered executable path. Returns
Nonewhen theCIenvironment variable is enabled (unlessCICPPis also enabled to opt back in), or when no candidate file exists and PATH lookup does not find the executable.
- onnx_light.doc.generate_operators_doc(output_dir: str, progress_callback: Callable[[str], None] | None = None) None#
Generates operator RST pages into output_dir.
Reads all ONNX operator schemas from the lightweight
onnx_opC extension (LightOpSchema) and writes one RST file per domain plus a top-levelindex.rsttoctree.- Parameters:
output_dir – Directory where the generated
.rstfiles are written. It is created if it does not already exist.progress_callback – Optional callback receiving progress messages while pages are generated.
- onnx_light.doc.get_cpu_topology() dict[str, int | None]#
Returns CPU topology information.
The returned mapping contains:
logical: number of logical processors (threads) available, orNoneif it cannot be determined.physical_cores: total number of physical cores across all sockets, orNoneif it cannot be determined.sockets: number of physical processors (sockets), orNoneif it cannot be determined.
On Linux,
/proc/cpuinfois parsed to derive physical core and socket counts. On other platforms (or when/proc/cpuinfois unavailable), only the logical processor count fromos.cpu_count()is reported.
- onnx_light.doc.get_processor_name() str#
Returns a human-readable processor name, falling back to
platformdata.
- onnx_light.doc.get_total_memory_gb() float | None#
Returns total system memory in GB, or
Noneif it cannot be determined.
- onnx_light.doc.measure_cpp_with_example(executable: str | None, args: list[str], metric_pattern: Pattern[str], result_name: str, executable_name: str) dict | None#
Runs a standalone C++ benchmark executable and parses its timing output.
- Parameters:
executable – Path to the C++ executable, or
Noneif unavailable.args – Arguments passed to the executable (not including the executable itself).
metric_pattern – Compiled regex pattern to match metric lines in stdout. Must capture the metric label in group 1 and the numeric value in group 2. The captured label must produce
"average","median","min", and"max"(case-folded) for the four required metrics, and may also produce"std"or"standard deviation".result_name – Benchmark name stored in the returned dictionary’s
namekey.executable_name – Human-readable executable name used in diagnostic messages.
- Returns:
A benchmark dictionary with keys
name,median,avg,min,max, andstdif successful, otherwiseNone.
- onnx_light.doc.render_rst_case(case: InferenceCaseReport) str#
Renders one test case as a reST section.
The section contains:
a
.. code-block:: textblock rendering the original model viapretty_onnx();either an error admonition (when shape inference raised) or a
list-tablecontrasting expected and computed shapes for every input, intermediate and output value.
- onnx_light.doc.render_rst_report(report: InferenceCoverageReport) str#
Renders every collected case back-to-back.
- onnx_light.doc.render_rst_summary(report: InferenceCoverageReport) str#
Renders a one-row summary as a reST
list-table.