Kernel classes#

class AbsKernel : public ONNX_LIGHT_NAMESPACE::core::runtime::KernelBase#

SIMD-accelerated onnx-light kernel for the ONNX Abs operator.

AbsKernel derives from onnx-light’s :cpp:class:onnx_light::core::runtime::KernelBase so it plugs into the runtime exactly like a built-in kernel: the dispatch table constructs it once per node and calls :cpp:func:Run on every execution. The computation uses private SIMD dispatch for every supported numeric type. Float16 and bfloat16 share the exact sign bit clearing path, while signed integers use width-specific SIMD absolute value operations.

Public Functions

void Run(ONNX_LIGHT_NAMESPACE::core::runtime::RuntimeContext &rt) override#

Reads the node’s single input, computes the elementwise absolute value and stores the single output back into rt.

ONNX_LIGHT_NAMESPACE::core::runtime::Tensor operator()(const ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &x, ONNX_LIGHT_NAMESPACE::core::runtime::RuntimeContext *rt = nullptr) const#

Allocates a fresh output tensor and writes |x| into it.

When rt is non-null its allocator backs the output buffer.

void operator()(const ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &x, ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &output) const#

Writes |x| into the caller-supplied output tensor, whose data_type, shape and buffer size must already match x.

Public Static Attributes

static constexpr const char *kName = "onnx_light_cpu::Abs"#

Library-qualified name identifying this kernel, recorded through :cpp:func:RecordKernelUsage on every :cpp:func:Run so callers can tell the onnx-light-cpu kernel apart from onnx-light’s built-in Abs.

class ExpKernel : public ONNX_LIGHT_NAMESPACE::core::runtime::KernelBase#

SIMD-accelerated onnx-light kernel for the ONNX Exp operator.

ExpKernel derives from onnx-light’s :cpp:class:onnx_light::core::runtime::KernelBase so it plugs into the runtime exactly like a built-in kernel: the dispatch table constructs it once per node and calls :cpp:func:Run on every execution. The computation uses private SIMD dispatch for float32/float64 directly; float16 and bfloat16 use vector conversion blocks around the same float32 approximation.

Public Functions

void Run(ONNX_LIGHT_NAMESPACE::core::runtime::RuntimeContext &rt) override#

Reads the node’s single input, computes the elementwise exponential and stores the single output back into rt.

ONNX_LIGHT_NAMESPACE::core::runtime::Tensor operator()(const ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &x, ONNX_LIGHT_NAMESPACE::core::runtime::RuntimeContext *rt = nullptr) const#

Allocates a fresh output tensor and writes exp(x) into it.

When rt is non-null its allocator backs the output buffer.

void operator()(const ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &x, ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &output) const#

Writes exp(x) into the caller-supplied output tensor, whose data_type, shape and buffer size must already match x.

Public Static Attributes

static constexpr const char *kName = "onnx_light_cpu::Exp"#

Library-qualified name identifying this kernel, recorded through :cpp:func:RecordKernelUsage on every :cpp:func:Run so callers can tell the onnx-light-cpu kernel apart from onnx-light’s built-in Exp.

class LogKernel : public ONNX_LIGHT_NAMESPACE::core::runtime::KernelBase#

SIMD-accelerated onnx-light kernel for the ONNX Log operator.

LogKernel mirrors :cpp:class:ExpKernel, using private SIMD dispatch for float32/float64, a scalar exact FP16 path, and vector conversion blocks for bfloat16.

Public Functions

void Run(ONNX_LIGHT_NAMESPACE::core::runtime::RuntimeContext &rt) override#

Reads the node’s single input, computes the elementwise natural logarithm and stores the single output back into rt.

ONNX_LIGHT_NAMESPACE::core::runtime::Tensor operator()(const ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &x, ONNX_LIGHT_NAMESPACE::core::runtime::RuntimeContext *rt = nullptr) const#

Allocates a fresh output tensor and writes log(x) into it.

When rt is non-null its allocator backs the output buffer.

void operator()(const ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &x, ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &output) const#

Writes log(x) into the caller-supplied output tensor, whose data_type, shape and buffer size must already match x.

Public Static Attributes

static constexpr const char *kName = "onnx_light_cpu::Log"#

Library-qualified name identifying this kernel, recorded through :cpp:func:RecordKernelUsage on every :cpp:func:Run so callers can tell the onnx-light-cpu kernel apart from onnx-light’s built-in Log.

class GemmKernel : public ONNX_LIGHT_NAMESPACE::core::runtime::KernelBase#

SIMD-accelerated onnx-light kernel for the ONNX Gemm operator.

GemmKernel derives from onnx-light’s :cpp:class:onnx_light::core::runtime::KernelBase so it plugs into the runtime exactly like a built-in kernel: the dispatch table constructs it once per node and calls :cpp:func:Run on every execution. The computation

Y = alpha * op(A) @ op(B) + beta * C
(where op(X) transposes X when the corresponding transA / transB attribute is set) uses private register-blocked SIMD dispatch for float32 and float64. float16 and bfloat16 inputs are accumulated in float32 and rounded back down for the output, matching common fp16/bf16 GEMM backend conventions. The optional bias C is consumed directly as a scalar, row, column, or matrix view without materializing an expanded M x N tensor. FP16/BF16 narrowing is combined with the bias epilogue.

Public Functions

explicit GemmKernel(const ONNX_LIGHT_NAMESPACE::core::runtime::KernelContext &ctx)#

Constructs the kernel and eagerly allocates the immutable-plan cache so no per-run lazy initialization (and its data race) is needed.

~GemmKernel() override#

Declared so the std::unique_ptr to the incomplete plan cache can be destroyed where the cache type is complete (in the translation unit).

void Run(ONNX_LIGHT_NAMESPACE::core::runtime::RuntimeContext &rt) override#

Reads the node’s A, B and optional C inputs together with the alpha, beta, transA and transB attributes, computes the general matrix multiplication and stores the single output back into rt.

ONNX_LIGHT_NAMESPACE::core::runtime::Tensor operator()(const ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &a, const ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &b, const ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &c, float alpha, float beta, bool trans_a, bool trans_b, ONNX_LIGHT_NAMESPACE::core::runtime::RuntimeContext *rt = nullptr) const#

Allocates a fresh output tensor and writes alpha * op(A) @ op(B) + beta * C into it, broadcasting the bias c to the M x N output shape.

When rt is non-null its allocator backs the output buffer.

ONNX_LIGHT_NAMESPACE::core::runtime::Tensor operator()(const ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &a, const ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &b, float alpha, bool trans_a, bool trans_b, ONNX_LIGHT_NAMESPACE::core::runtime::RuntimeContext *rt = nullptr) const#

Same as above but for a Gemm node without a bias input: allocates a fresh output tensor and writes alpha * op(A) @ op(B) into it.

Public Static Functions

static std::int64_t ActiveInstanceCountForTesting() noexcept#

Returns the number of live instances in this library.

Intended for lifecycle regression tests that verify lazy backend-test registration.

Public Static Attributes

static constexpr const char *kName = "onnx_light_cpu::Gemm"#

Library-qualified name identifying this kernel, recorded through :cpp:func:RecordKernelUsage on every :cpp:func:Run so callers can tell the onnx-light-cpu kernel apart from onnx-light’s built-in Gemm.

class NotKernel : public ONNX_LIGHT_NAMESPACE::core::runtime::KernelBase#

SIMD-accelerated onnx-light kernel for the ONNX Not operator.

NotKernel derives from onnx-light’s :cpp:class:onnx_light::core::runtime::KernelBase so it plugs into the runtime exactly like a built-in kernel: the dispatch table constructs it once per node and calls :cpp:func:Run on every execution. The computation uses private SIMD dispatch. ONNX Not only accepts bool inputs, so the kernel is a full drop-in replacement for the built-in one.

Public Functions

void Run(ONNX_LIGHT_NAMESPACE::core::runtime::RuntimeContext &rt) override#

Reads the node’s single input, computes the elementwise logical negation and stores the single output back into rt.

ONNX_LIGHT_NAMESPACE::core::runtime::Tensor operator()(const ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &x, ONNX_LIGHT_NAMESPACE::core::runtime::RuntimeContext *rt = nullptr) const#

Allocates a fresh output tensor and writes !x into it.

When rt is non-null its allocator backs the output buffer.

void operator()(const ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &x, ONNX_LIGHT_NAMESPACE::core::runtime::Tensor &output) const#

Writes !x into the caller-supplied output tensor, whose data_type, shape and buffer size must already match x.

Public Static Attributes

static constexpr const char *kName = "onnx_light_cpu::Not"#

Library-qualified name identifying this kernel, recorded through :cpp:func:RecordKernelUsage on every :cpp:func:Run so callers can tell the onnx-light-cpu kernel apart from onnx-light’s built-in Not.