Kernel inventory and usage#

registered_kernel_names() → dict[str, str]#

Returns a {op_type: kernel name} mapping for accelerated registered kernels, for example {"Abs": "onnx_light_cpu::Abs"}. Use it to confirm that accelerated rather than built-in kernels are registered. The mapping is derived from registered_kernels() rather than a separate operator list.

class RegisteredKernel#

Immutable record describing one kernel registration.

domain: str#

ONNX operator domain, e.g. "ai.onnx".

op_type: str#

ONNX operator type name, e.g. "Abs".

device: str#

Device the kernel runs on, e.g. "CPU".

kernel_name: str#

Library-qualified C++ kernel class name, e.g. "onnx_light_cpu::Abs".

types: tuple[str, ...]#

Element type names accepted for primary tensor operands.

since_version: int | None#

Inclusive opset lower bound, or None without a lower bound.

until_version: int | None#

Inclusive opset upper bound, or None without an upper bound.

registered_kernels() → tuple[RegisteredKernel, ...]#

Returns registrations collected from the C++ CollectRegisteredKernels() inventory without executing kernels.

used_kernel_names(sess) → list[str]#

Returns an independent, non-consuming snapshot of all participating backend kernel names recorded by sess since its last clear_used_kernel_names() call. The session retains its first 1024 invocations and drops later entries until cleared. Concurrent records are ordered by acquisition of the recorder’s mutex.

used_kernel_paths(sess) → list[str]#

Returns the recorded kernel names plus implementation-path diagnostics such as Cast.float32_to_float16.f16c or onnx_light_cpu::SimplifiedLayerNormalization/avx/row-scale. Use this when reporting which SIMD or fallback path a kernel selected; used_kernel_names() remains limited to kernel identities.

clear_used_kernel_names(sess) → None#

Clears the recorded backend-kernel invocations for sess without changing whether recording is enabled.

set_kernel_usage_recording(sess, enabled) → None#

Enables or disables per-invocation kernel usage recording for sess. Recording is disabled by default; disabling preserves existing entries.

All three functions require an explicit onnx_light.onnx.reference.ReferenceEvaluator session and raise TypeError for a missing or invalid session. Recording is owned by its native RuntimeContext: copies, subgraphs, and functions belonging to that context share the recording state, while independent sessions are isolated. The returned names are not filtered to onnx_light_cpu kernels.

The former process-wide, session-free recording API was intentionally removed; there is no global compatibility fallback. These functions require an updated onnx-light containing PR #4942. No minimum released version is specified yet because that upstream change has not been released.