onnx_light.tools.kernel_inventory#
Enumerates every registered native kernel path and classifies its coverage.
This module implements Step D of
Kernel parallelization and tuning sequence: it builds one inventory row per
(domain, op_type, device, element_type, implementation) path covering
every operator registered in the built-in
onnx_kernels::BuiltinKernelFunctions dispatch table
(onnx_light/onnx_extensions/kernels/kernel_dispatch_table.cc).
Each row is classified into exactly one coverage state:
serialNo
ParallelForcall site was found in the kernel’s implementation file and no tuning schema is registered for it.parallel_fixed_policyThe kernel calls
ParallelForbut has no registered tuning schema, so its grain size and participant limits are compiled constants.tunableThe kernel registers a
KernelTuningSchema(a portable default that may be overridden by a persisted profile).calibratableA
tunablepath that additionally registers aKernelCalibrationFunction.
Building the inventory only reads static kernel source files and the
in-process tuning registry (via
onnx_light.kernel_tuning.kernel_tuning_parameters()); it never mutates
the kernel tuning cache.
- onnx_light.tools.kernel_inventory.build_kernel_inventory(*, library: str = 'onnx_light', dispatch_table_path: Path | str | None = None, kernel_source_root: Path | str | None = None, tuning_report: dict[str, Any] | None = None) list[dict[str, Any]]#
Builds the full kernel-path inventory (Step D).
- Parameters:
library – Tuning library identifier passed to
onnx_light.kernel_tuning.kernel_tuning_parameters()whentuning_reportis not supplied.dispatch_table_path – Optional override of the dispatch-table source path.
kernel_source_root – Optional override of the kernel implementation source root.
tuning_report – Optional pre-fetched
kernel_tuning_parameters()result, mainly for tests that must not depend on the compiled extension.
- Returns:
A list of inventory rows, sorted by
(domain, op_type, element_type, implementation). Every registered kernel path appears exactly once.
- onnx_light.tools.kernel_inventory.dispatch_table_entries(dispatch_table_path: Path | str | None = None) list[tuple[str, str, str]]#
Parses the built-in kernel dispatch table into
(domain, op_type, class_name)rows.- Parameters:
dispatch_table_path – Optional override of the
kernel_dispatch_table.ccpath, mainly for tests.- Returns:
One entry per registered
(domain, op_type)identifier, in file order.
- onnx_light.tools.kernel_inventory.validate_inventory(rows: list[dict[str, Any]]) None#
Raises
ValueErrorwhen a kernel path is missing or duplicated.- Parameters:
rows – The result of
build_kernel_inventory().- Raises:
ValueError – When two rows share the same
(domain, op_type, device, element_type, implementation)identity, or when a row is missing an explicitcoverage_state.