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
Abskernel into onnx-light’s sharedKernelDispatchTablefor the CPU device.After this call, every
Absnode dispatched by onnx-light’s runtime (RunNode/RuntimeSession, and therefore any model executed throughReferenceEvaluator) resolves to :cpp:class:AbsKernel, so any ONNX model usingAbsruns the SIMD-accelerated kernel. Registering under the default ONNX domain replaces the built-inAbsentry.
-
void onnx_light_cpu::RegisterExpKernel()#
Registers the onnx-light-cpu
Expkernel into onnx-light’s sharedKernelDispatchTablefor the CPU device.After this call, every
Expnode dispatched by onnx-light’s runtime (RunNode/RuntimeSession, and therefore any model executed throughReferenceEvaluator) resolves to :cpp:class:ExpKernel. Registering under the default ONNX domain replaces the built-inExpentry.
-
void onnx_light_cpu::RegisterLogKernel()#
Registers the onnx-light-cpu
Logkernel into onnx-light’s sharedKernelDispatchTablefor the CPU device, replacing the built-inLogentry with :cpp:class:LogKernel.
-
void onnx_light_cpu::RegisterGemmKernel()#
Registers the onnx-light-cpu
Gemmkernel into onnx-light’s sharedKernelDispatchTablefor the CPU device.After this call, every
Gemmnode dispatched by onnx-light’s runtime (RunNode/RuntimeSession, and therefore any model executed throughReferenceEvaluator) resolves to :cpp:class:GemmKernel, so any ONNX model usingGemmruns the SIMD-accelerated kernel. Registering under the default ONNX domain replaces the built-inGemmentry.
-
void onnx_light_cpu::RegisterNotKernel()#
Registers the onnx-light-cpu
Notkernel into onnx-light’s sharedKernelDispatchTablefor the CPU device.After this call, every
Notnode dispatched by onnx-light’s runtime (RunNode/RuntimeSession, and therefore any model executed throughReferenceEvaluator) resolves to :cpp:class:NotKernel. Registering under the default ONNX domain replaces the built-inNotentry.
-
void onnx_light_cpu::RegisterAllKernels()#
Registers every onnx-light-cpu kernel class into onnx-light’s shared
KernelDispatchTablefor 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 materializedAttentionbaseline, the preparedTreeEnsemblekernel, the portable integer matrix-multiplication kernels, and thecom.microsoftBiasGelu/CDistcontrib kernels. After this call every such node dispatched by onnx-light’s runtime (RunNode/RuntimeSession, and therefore any model executed throughReferenceEvaluator) 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.microsoftfamily 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. Ifreplaceis false, an existing registration is retained and this function returns false. Unknown domain/operator pairs throwstd::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
replacefalse, 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
RuntimeContextowns the registration. It takes precedence over global and built-in kernels for that session and is destroyed with the context. Ifreplaceis 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.microsoftoperator.