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.

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::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 onnx-light-cpu kernel class into onnx-light’s shared KernelDispatchTable for the CPU device.

This is a convenience wrapper that calls each per-operator registration function (:cpp:func:RegisterAbsKernel, :cpp:func:RegisterAttentionKernel, :cpp:func:RegisterBiasGeluKernel, :cpp:func:RegisterBinaryKernels, :cpp:func:RegisterCDistKernel, :cpp:func:RegisterExpKernel, :cpp:func:RegisterLogKernel, :cpp:func:RegisterGemmKernel, :cpp:func:RegisterMatMulKernel, :cpp:func:RegisterIntegerMatMulKernels :cpp:func:RegisterNotKernel, :cpp:func:RegisterTreeEnsembleKernel, and :cpp:func:RegisterVariadicElementwiseKernels), so a single call installs the accelerated elementwise/GEMM kernels, the stateless materialized Attention baseline, the prepared TreeEnsemble kernel, the portable integer matrix-multiplication kernels, and the com.microsoft BiasGelu/CDist contrib kernels. After this call every such node dispatched by onnx-light’s runtime (RunNode / RuntimeSession, and therefore any model executed through ReferenceEvaluator) resolves to the onnx-light-cpu kernel, replacing the corresponding built-in entries for the default ONNX domain.

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.

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.