Kernel registration#

When onnx-light-cpu is built with -DONNX_LIGHT_CPU_WITH_ONNX_LIGHT=ON (which requires the onnx-light C++ package), it produces lib_onnx_light_cpu_kernels. Its runtime inventory is available from CollectRegisteredKernels() and the generated ByOp catalogue.

The integration links onnx_light::lib_onnx_kernels for Cast’s built-in compatibility conversions, even when backend tests are disabled. Source runtime builds find this library next to the selected core library; ONNX_LIGHT_CPU_ONNX_LIGHT_KERNELS_LIBRARY can select it explicitly.

void onnx_light_cpu::RegisterAbsKernel()#

Registers the onnx-light-cpu Abs kernel into onnx-light’s shared KernelDispatchTable for the CPU device.

After this call, every Abs node dispatched by onnx-light’s runtime (RunNode / RuntimeSession, and therefore any model executed through ReferenceEvaluator) resolves to :cpp:class:AbsKernel, so any ONNX model using Abs runs the SIMD-accelerated kernel. Registering under the default ONNX domain replaces the built-in Abs entry.

void onnx_light_cpu::RegisterExpKernel()#

Registers the onnx-light-cpu Exp kernel into onnx-light’s shared KernelDispatchTable for the CPU device.

After this call, every Exp node dispatched by onnx-light’s runtime (RunNode / RuntimeSession, and therefore any model executed through ReferenceEvaluator) resolves to :cpp:class:ExpKernel. Registering under the default ONNX domain replaces the built-in Exp entry.

void onnx_light_cpu::RegisterLogKernel()#

Registers the onnx-light-cpu Log kernel into onnx-light’s shared KernelDispatchTable for the CPU device, replacing the built-in Log entry with :cpp:class:LogKernel.

void onnx_light_cpu::RegisterGemmKernel()#

Registers the onnx-light-cpu Gemm kernel into onnx-light’s shared KernelDispatchTable for the CPU device.

After this call, every Gemm node dispatched by onnx-light’s runtime (RunNode / RuntimeSession, and therefore any model executed through ReferenceEvaluator) resolves to :cpp:class:GemmKernel, so any ONNX model using Gemm runs the SIMD-accelerated kernel. Registering under the default ONNX domain replaces the built-in Gemm entry.

void onnx_light_cpu::RegisterGatherKernel()#
void onnx_light_cpu::RegisterCastKernel()#
void onnx_light_cpu::RegisterSliceKernel()#
void onnx_light_cpu::RegisterConcatKernel()#
void onnx_light_cpu::RegisterSplitKernel()#
void onnx_light_cpu::RegisterNotKernel()#

Registers the onnx-light-cpu Not kernel into onnx-light’s shared KernelDispatchTable for the CPU device.

After this call, every Not node dispatched by onnx-light’s runtime (RunNode / RuntimeSession, and therefore any model executed through ReferenceEvaluator) resolves to :cpp:class:NotKernel. Registering under the default ONNX domain replaces the built-in Not entry.

void onnx_light_cpu::RegisterAllKernels()#

Registers every shipped operator into onnx-light’s process-wide KernelDispatchTable for the CPU device.

See :ref:l-register-all-kernels-inventory for the complete family, domain, and operator table, validated against CollectRegisteredKernels. The inventory covers ai.onnx (also accepted as the empty domain), ai.onnx.ml, and com.microsoft.

Existing global entries are replaced. Register before nodes are resolved: already-resolved sessions retain cached factories, and session-local overrides take precedence. Use RegisterAllKernelsForSession to install the same operator set on one RuntimeContext without changing global state, or RegisterAllKernelsGlobal for explicit replacement control.

This overload selects MicrosoftKernelImplementation::OPTIMIZED. The policy overload can instead select the complete NAIVE Microsoft reference family; it does not change the ONNX or ONNX-ML registrations. Optimized kernels may still use scalar fallbacks depending on types, shapes, build options, and available CPU instructions.

void onnx_light_cpu::RegisterAllKernels(MicrosoftKernelImplementation implementation)#

Registers all kernels, selecting the complete com.microsoft family explicitly.

The no-argument overload is equivalent to OPTIMIZED.

bool onnx_light_cpu::RegisterKernelGlobal(const std::string &domain, const std::string &op_type, bool replace = true, MicrosoftKernelImplementation implementation = MicrosoftKernelImplementation::OPTIMIZED)#

Registers one shipped kernel in the process-wide dispatch table.

The empty domain and "ai.onnx" are equivalent. If replace is false, an existing registration is retained and this function returns false. Unknown domain/operator pairs throw std::invalid_argument.

std::size_t onnx_light_cpu::RegisterAllKernelsGlobal(bool replace = true, MicrosoftKernelImplementation implementation = MicrosoftKernelImplementation::OPTIMIZED)#

Registers every shipped kernel in the process-wide dispatch table.

Returns the number of factories installed. With replace false, repeated calls are idempotent and return zero once all entries exist.

bool onnx_light_cpu::RegisterKernelForSession(ONNX_LIGHT_NAMESPACE::core::runtime::RuntimeContext &session, const std::string &domain, const std::string &op_type, bool replace = true, MicrosoftKernelImplementation implementation = MicrosoftKernelImplementation::OPTIMIZED)#

Registers one shipped kernel only on session.

The session’s RuntimeContext owns the registration. It takes precedence over global and built-in kernels for that session and is destroyed with the context. If replace is false, an existing session-local registration is retained and this function returns false. Native factories participate in RuntimeSession’s preparation and tuning lifecycle. The runtime retains the configured instances across runs; already-prepared sessions retain their instances after replacement.

std::size_t onnx_light_cpu::RegisterAllKernelsForSession(ONNX_LIGHT_NAMESPACE::core::runtime::RuntimeContext &session, bool replace = true, MicrosoftKernelImplementation implementation = MicrosoftKernelImplementation::OPTIMIZED)#

Registers every shipped kernel only on session.

Returns the number of session-local registrations installed.

void onnx_light_cpu::RegisterMicrosoftKernels(MicrosoftKernelImplementation implementation)#

Registers exactly one implementation for every com.microsoft operator.

enum class onnx_light_cpu::MicrosoftKernelImplementation#

Selects the complete com.microsoft kernel implementation family.

Values:

enumerator NAIVE#

Readable scalar correctness-oracle implementations.

enumerator OPTIMIZED#

Production implementations with tuning, SIMD, and parallel execution.