include_math_kernels.h#

namespace onnx_light

Alias that makes onnx-light headers compatible with code that references ONNX_LIGHT_NAMESPACE (the macro used in the standard onnx package).

Set to ONNX_LIGHT_NAMESPACE so both names resolve to the same namespace.

Symbol-visibility attribute for the public onnx-light C++ API.

Defined as empty because onnx-light does not require explicit __declspec(dllexport) or __attribute__((visibility("default"))) annotations — visibility is controlled at the shared-library level. The macro is provided so that vendored ONNX headers that decorate their declarations with ONNX_API compile without modification.

Namespace alias so that ONNX C++ code (and consumers such as onnxruntime) that refers to the literal onnx namespace — rather than the ONNX_NAMESPACE macro — resolves to the onnx-light namespace. The standard onnx package lives in namespace onnx; onnx-light uses onnx_light (via ONNX_LIGHT_NAMESPACE), so this alias keeps onnx-light a true drop-in. It is only introduced when the onnx-light namespace differs from onnx.

namespace onnx_kernels
namespace kernel
class Abs : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise absolute value.

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Acos : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise arc cosine: y = acos(x), with x in [-1, 1] and y in [0, pi].

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Acosh : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise inverse hyperbolic cosine: y = acosh(x), with x >= 1.

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Add : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise addition with NumPy-style broadcasting.

Public Functions

Tensor operator()(const Tensor &x, const Tensor &y) const#
void operator()(const Tensor &x, const Tensor &y, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise binary kernel: the output buffer may alias an input buffer when that input is not broadcast-expanded (i.e. its shape equals the output shape).

class Asin : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise arc sine: y = asin(x), with x in [-1, 1] and y in [-pi/2, pi/2].

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Asinh : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise inverse hyperbolic sine: y = asinh(x), defined for all real x.

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Atan : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise arc tangent: y = atan(x), defined for all real x.

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Atanh : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise inverse hyperbolic tangent: y = atanh(x), with x in (-1, 1).

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class BlackmanWindow : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

BlackmanWindow function evaluated at size integer samples. When periodic is true the window is computed as if of length size+1 and the last sample is discarded (matches NumPy/ONNX conventions).

Public Functions

Tensor operator()(const Tensor &size, bool periodic = true) const#
void operator()(const Tensor &size, bool periodic, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Output is a float vector while the input is an int scalar: storage can never be shared with an input.

class Ceil : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise ceiling: y = ceil(x), the smallest integer >= x.

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Celu : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise continuously differentiable exponential linear unit: y = max(0, x) + min(0, alpha * (exp(x / alpha) - 1)). alpha defaults to 1.0 to match the ONNX schema. Only FLOAT inputs are accepted (matching the v12 schema).

Public Functions

Tensor operator()(const Tensor &x, float alpha = 1.0f) const#
void operator()(const Tensor &x, float alpha, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Clip : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise clip: y = min(max(x, min_val), max_val) (since opset 6).

Both min and max are optional scalar tensors (since opset 11); when omitted, the corresponding bound defaults to std::numeric_limits<T>::lowest() and std::numeric_limits<T>::max(). When min > max the operator returns max for every element, matching the ONNX specification (Min(max, Max(input, min))).

Public Functions

Tensor operator()(const Tensor &x, const Tensor *min = nullptr, const Tensor *max = nullptr) const#

Computes y = clip(x, min, max). min/max may be nullptr to use the dtype-specific default bound. When provided, each must be a 0-D (scalar) tensor whose dtype matches x.

void operator()(const Tensor &x, const Tensor *min, const Tensor *max, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Cos : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise cosine: y = cos(x), defined for all real x with y in [-1, 1].

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Cosh : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise hyperbolic cosine: y = cosh(x), defined for all real x with y >= 1.

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class CumProd : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Cumulative product of the input tensor along axis. Semantics mirror :class:CumSum with addition replaced by multiplication; in exclusive mode the starting value is 1 (multiplicative identity).

Public Functions

Tensor operator()(const Tensor &x, const Tensor &axis, bool exclusive = false, bool reverse = false) const#
void operator()(const Tensor &x, const Tensor &axis, bool exclusive, bool reverse, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

See :class:CumSum.

class CumSum : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

INT32 or INT64 tensor whose value selects the dimension along which the cumulative sum is computed (negative values count from the back). The exclusive flag, when true, excludes the current element from each position’s running sum (the j-th output element is the sum of the first j-1 elements; the 0-th element becomes 0). The reverse flag, when true, performs the summation in the opposite direction along axis.

Public Functions

Tensor operator()(const Tensor &x, const Tensor &axis, bool exclusive = false, bool reverse = false) const#
void operator()(const Tensor &x, const Tensor &axis, bool exclusive, bool reverse, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Each output element depends on a previous output element along axis; aliasing input and output buffers is safe because we always read the current element before writing the output at the same position. The exclusive mode reads the previous position’s input before writing, which is also safe in row-major order when iterating outward from the starting end.

class Det : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Determinant of a square matrix or batches of square matrices.

The input must have shape [*, M, M] (rank >= 2) with the inner-most two dimensions forming square matrices. The output has shape [*] (the leading batch dimensions); when the input is 2-D the output is a scalar (rank-0). Both input and output are FLOAT tensors.

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

The output buffer is smaller than the input (drops the trailing two dimensions); storage can never be shared with the input.

class DFT : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Reference implementation of the ONNX DFT operator (since opset 17; in opset 20 the axis attribute moved to an optional third input).

Computes the (one-dimensional) discrete Fourier Transform of input along axis. input must be a floating-point tensor of rank >= 2, where the trailing dimension is 1 (real-valued samples) or 2 (interleaved real/imaginary parts). The returned tensor has the same rank as input; its last dimension is 2 (complex output) except for IRFFT (onesided=1 and inverse=1), in which case it is 1.

When dft_length is specified the signal is zero-padded or truncated along axis; otherwise the axis dimension is used (or 2 * (signal_dim_axis - 1) for the IRFFT default).

Public Functions

Tensor operator()(const Tensor &input, const Tensor *dft_length, int64_t axis, bool onesided = false, bool inverse = false) const#

axis is the signal axis (must satisfy -rank <= axis, axis != -1 and axis < rank - 1). dft_length is a pointer to a 0-D INT32/INT64 tensor; pass nullptr to use the default.

void operator()(const Tensor &input, const Tensor *dft_length, int64_t axis, bool onesided, bool inverse, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

The output shape (last dim and signal axis) generally differs from the input shape, so storage cannot be shared.

class Div : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise division with NumPy-style broadcasting.

Public Functions

Tensor operator()(const Tensor &x, const Tensor &y) const#
void operator()(const Tensor &x, const Tensor &y, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise binary kernel: the output buffer may alias an input buffer when that input is not broadcast-expanded (i.e. its shape equals the output shape).

class Einsum : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Reference implementation of the Einsum operator (opset 12).

Evaluates the Einstein summation expressed by equation over the list of input tensors. The equation may contain ellipsis (...) to broadcast leading dimensions, and may be given either in explicit form (-> followed by the output term) or implicit form. All inputs must share the same dtype (FLOAT or DOUBLE); the output has the same dtype.

Public Functions

Tensor operator()(const std::vector<Tensor> &inputs, const std::string &equation) const#
void operator()(const std::vector<Tensor> &inputs, const std::string &equation, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Einsum generally changes shape and cannot alias inputs safely.

class Elu : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise exponential linear unit: y = x for x >= 0 and y = alpha * (exp(x) - 1) otherwise. alpha defaults to 1.0 to match the ONNX schema.

Public Functions

Tensor operator()(const Tensor &x, float alpha = 1.0f) const#
void operator()(const Tensor &x, float alpha, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Erf : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise error function: y = erf(x), defined for all real x.

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Exp : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise exponential: y = exp(x), defined for all real x.

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Floor : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise floor: y = floor(x), the largest integer <= x.

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Gelu : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise gaussian error linear unit. When approximate == "none" (the default) the exact formulation y = 0.5 * x * (1 + erf(x / sqrt(2))) is used; when approximate == "tanh" the tanh-based approximation y = 0.5 * x * (1 + tanh(sqrt(2/pi) * (x + 0.044715 * x^3))) is used.

Public Functions

Tensor operator()(const Tensor &x, const std::string &approximate = "none") const#
void operator()(const Tensor &x, const std::string &approximate, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Gemm : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

General matrix multiplication: Y = alpha * op(A) * op(B) + beta * C. transA/transB control whether A and B are transposed (0 = no, non-zero = yes); alpha and beta are scalar multipliers. When c is nullptr the bias term is omitted (treated as zero).

Public Functions

Tensor operator()(const Tensor &a, const Tensor &b, const Tensor *c, float alpha, float beta, int64_t transA, int64_t transB) const#
void operator()(const Tensor &a, const Tensor &b, const Tensor *c, float alpha, float beta, int64_t transA, int64_t transB, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Gemm produces a new matrix that cannot alias any input.

class HammingWindow : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

HammingWindow function evaluated at size integer samples. When periodic is true the window is computed as if of length size+1 and the last sample is discarded (matches NumPy/ONNX conventions).

Public Functions

Tensor operator()(const Tensor &size, bool periodic = true) const#
void operator()(const Tensor &size, bool periodic, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Output is a float vector while the input is an int scalar: storage can never be shared with an input.

class HannWindow : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

HannWindow function evaluated at size integer samples. When periodic is true the window is computed as if of length size+1 and the last sample is discarded (matches NumPy/ONNX conventions).

Public Functions

Tensor operator()(const Tensor &size, bool periodic = true) const#
void operator()(const Tensor &size, bool periodic, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Output is a float vector while the input is an int scalar: storage can never be shared with an input.

class Hardmax : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Hardmax: emits 1 at the position of the first maximum value along axis, 0 elsewhere. The output has the same shape and dtype as the input.

Public Functions

Tensor operator()(const Tensor &x, int64_t axis) const#
void operator()(const Tensor &x, int64_t axis, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Hardmax must look at every value along the axis before it can write any output, so it cannot run in place safely.

class HardSigmoid : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise HardSigmoid activation: y = max(0, min(1, alpha * x + beta)).

Public Functions

Tensor operator()(const Tensor &x, float alpha, float beta) const#
void operator()(const Tensor &x, float alpha, float beta, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class HardSwish : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise HardSwish activation: y = x * max(0, min(1, x/6 + 0.5)) = x * HardSigmoid(x; alpha=1/6, beta=0.5).

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class LeakyRelu : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise leaky rectified linear unit: y = x for x >= 0 and y = alpha * x otherwise. alpha defaults to 0.01 to match the ONNX schema.

Public Functions

Tensor operator()(const Tensor &x, float alpha = 0.01f) const#
void operator()(const Tensor &x, float alpha, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Log : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise natural logarithm: y = log(x), with x > 0.

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class LogSoftmax : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

LogSoftmax: log of the normalized exponential along a selected axis.

Public Functions

Tensor operator()(const Tensor &x, int64_t axis) const#
void operator()(const Tensor &x, int64_t axis, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

LogSoftmax needs the full input slice to compute each output value; aliasing input/output would overwrite values needed for later positions.

class MatMul : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Matrix product that behaves like NumPy/ONNX matmul.

Supports rank-1 and rank-N inputs:

  • rank-1 x rank-1 -> scalar

  • rank-2 x rank-2 -> matrix

  • higher-rank prefixes are broadcast, then batched matrix multiply

Public Functions

Tensor operator()(const Tensor &a, const Tensor &b) const#
void operator()(const Tensor &a, const Tensor &b, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

MatMul generally changes shape and cannot alias inputs safely.

class MatMulInteger : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Reference MatMulInteger kernel (opset 10). Computes Y = matmul(A - a_zero_point, B - b_zero_point) with INT8/UINT8 inputs and an INT32 output. a_zero_point and b_zero_point are optional and default to 0 when default-constructed (empty) tensors are passed. This reference implementation handles per-tensor (scalar or one-element 1-D) zero points.

Public Functions

Tensor operator()(const Tensor &a, const Tensor &b, const Tensor &a_zero_point, const Tensor &b_zero_point) const#

Returning overload allocating an INT32 output. a_zero_point / b_zero_point may be default-constructed (empty) tensors meaning the optional input is absent.

void operator()(const Tensor &a, const Tensor &b, const Tensor &a_zero_point, const Tensor &b_zero_point, Tensor &output) const#

In-place overload writing into a caller-allocated INT32 output.

inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Output dtype (INT32) differs from inputs (INT8/UINT8), so storage cannot be shared with an input.

class Max : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise maximum of a list of tensors with NumPy-style (multidirectional) broadcasting. At least one input is required. All inputs must share the same numeric dtype (FLOAT, DOUBLE, INT8, INT16, INT32, INT64, UINT8, UINT16, UINT32 or UINT64); the output has the broadcast shape of all inputs and the same dtype.

Public Functions

Tensor operator()(const std::vector<Tensor> &inputs) const#
void operator()(const std::vector<Tensor> &inputs, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Variadic element-wise kernel: the output buffer may alias an input buffer when that input is not broadcast-expanded.

class Mean : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise mean of a list of tensors with NumPy-style (multidirectional) broadcasting. At least one input is required. All inputs must share the same float dtype (FLOAT or DOUBLE); the output has the broadcast shape of all inputs and the same dtype. The result is the element-wise sum of all inputs divided by the number of inputs.

Public Functions

Tensor operator()(const std::vector<Tensor> &inputs) const#
void operator()(const std::vector<Tensor> &inputs, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Variadic element-wise kernel: the output buffer may alias an input buffer when that input is not broadcast-expanded.

class MelWeightMatrix : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

MelWeightMatrix generates the triangular Mel filter-bank weight matrix used to re-weight a linearly sampled frequency spectrum into Mel-scaled bands (since opset 17). The output has shape [floor(dft_length/2) + 1, num_mel_bins] with element type output_dtype (default FLOAT).

Public Functions

Tensor operator()(const Tensor &num_mel_bins, const Tensor &dft_length, const Tensor &sample_rate, const Tensor &lower_edge_hertz, const Tensor &upper_edge_hertz, DataType output_dtype = DataType::FLOAT) const#
void operator()(const Tensor &num_mel_bins, const Tensor &dft_length, const Tensor &sample_rate, const Tensor &lower_edge_hertz, const Tensor &upper_edge_hertz, DataType output_dtype, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Output shape is unrelated to input shapes (all inputs are scalars): storage cannot be shared with an input.

class Min : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise minimum of a list of tensors with NumPy-style (multidirectional) broadcasting. At least one input is required. All inputs must share the same numeric dtype (FLOAT, DOUBLE, INT8, INT16, INT32, INT64, UINT8, UINT16, UINT32 or UINT64); the output has the broadcast shape of all inputs and the same dtype.

Public Functions

Tensor operator()(const std::vector<Tensor> &inputs) const#
void operator()(const std::vector<Tensor> &inputs, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

See :class:Max.

class Mish : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise Mish activation: y = x * tanh(softplus(x)) = x * tanh(ln(1 + exp(x))).

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Mod : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise modulo with NumPy-style broadcasting. The fmod flag controls the semantics:

  • fmod == 0 (default): integer modulo whose sign follows the divisor (Python % / numpy.mod). Only valid for integer dtypes.

  • fmod == 1: C fmod semantics whose sign follows the dividend. Required when either input is floating point and also accepted for integer inputs (where it coincides with C % truncated modulo).

Public Functions

Tensor operator()(const Tensor &x, const Tensor &y, int64_t fmod = 0) const#
void operator()(const Tensor &x, const Tensor &y, int64_t fmod, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise binary kernel: the output buffer may alias an input buffer when that input is not broadcast-expanded (i.e. its shape equals the output shape).

class Mul : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise multiplication with NumPy-style broadcasting.

Public Functions

Tensor operator()(const Tensor &x, const Tensor &y) const#
void operator()(const Tensor &x, const Tensor &y, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise binary kernel: the output buffer may alias an input buffer when that input is not broadcast-expanded (i.e. its shape equals the output shape).

class Neg : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise negation: y = -x. Mirrors the upstream ONNX Neg reference implementation (np.negative). Only the FLOAT dtype is supported.

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class NegativeLogLikelihoodLoss : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

NegativeLogLikelihoodLoss computes the (optionally weighted) negative log-likelihood loss given an input tensor of log-probabilities of shape (N, C) or (N, C, D1, ..., Dk) and integer class indices target of shape (N) or (N, D1, ..., Dk). Unlike SoftmaxCrossEntropyLoss, the input is assumed to already contain log-probabilities (no softmax is applied internally).

Public Functions

Tensor operator()(const Tensor &input, const Tensor &target, const Tensor *weight, const std::string &reduction, bool has_ignore_index, int64_t ignore_index) const#
Parameters:
  • input – Log-probabilities of shape (N, C) or (N, C, D1, ..., Dk).

  • target – Integer class indices of shape (N) or (N, D1, ..., Dk).

  • weightOptional rank-1 tensor of length C; nullptr means unweighted.

  • reduction – One of "none", "sum", or "mean".

  • has_ignore_index – Whether ignore_index is set.

  • ignore_index – Class index to ignore (only used when has_ignore_index is true).

Returns:

Loss tensor whose shape depends on reduction: matches the shape of target for "none"; scalar otherwise.

inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

The kernel allocates new outputs; it does not support input/output aliasing.

class Pow : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise exponentiation z = x ^ y with NumPy-style multidirectional broadcasting (since opset 7). Unlike most binary element-wise kernels, Pow allows x and y to have different dtypes: the output dtype always matches the dtype of the base x (per the ONNX schema, Z is constrained to T while Y is constrained to the broader T1).

Supported base dtypes (T): FLOAT, INT32, INT64. Supported exponent dtypes (T1): FLOAT, INT32, INT64, UINT32, UINT64. Integer base / integer exponent pairs evaluate the power in double precision and cast the result back to the base dtype, matching the reference behaviour of NumPy’s numpy.power and the upstream ONNX backend test cases.

Public Functions

Tensor operator()(const Tensor &x, const Tensor &y) const#
void operator()(const Tensor &x, const Tensor &y, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise binary kernel: the output buffer may alias the base input buffer when that input is not broadcast-expanded (i.e. its shape equals the output shape). Aliasing the exponent is generally not safe because it may have a different dtype than the output.

class PRelu : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise parametric ReLU: y = x when x >= 0 and y = slope * x otherwise. The slope tensor is unidirectionally broadcastable to x (the standard NumPy-style multidirectional broadcasting rules apply here as well — the unidirectional case is a strict subset). Float-input semantics preserve +inf/-inf because the kernel branches on the sign of x rather than evaluating max(0, x) + slope * min(0, x) (which would yield NaN for infinite inputs; see microsoft/onnxruntime#28732).

Public Functions

Tensor operator()(const Tensor &x, const Tensor &slope) const#
void operator()(const Tensor &x, const Tensor &slope, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise binary kernel: the output buffer may alias an input buffer when that input is not broadcast-expanded (i.e. its shape equals the output shape).

class Reciprocal : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise reciprocal: y = 1 / x (Inf for x = 0).

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Relu : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise rectified linear unit: y = max(0, x). Defined for both floating-point and signed integer tensors (see schema since v14).

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Round : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise round to nearest integer, ties to even (banker’s rounding).

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Selu : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise scaled exponential linear unit: y = gamma * x for x > 0 and y = gamma * (alpha * exp(x) - alpha) for x <= 0. alpha and gamma default to the ONNX schema defaults (~1.6732632 and ~1.0507009 respectively).

Public Functions

Tensor operator()(const Tensor &x, float alpha = 1.67326319217681884765625f, float gamma = 1.05070102214813232421875f) const#
void operator()(const Tensor &x, float alpha, float gamma, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Shrink : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise Shrink activation: y = x + bias if x < -lambd, y = x - bias if x > lambd, y = 0 otherwise. lambd defaults to 0.5 and bias defaults to 0.

Public Functions

Tensor operator()(const Tensor &x, float bias = 0.0f, float lambd = 0.5f) const#
void operator()(const Tensor &x, float bias, float lambd, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Sigmoid : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise logistic sigmoid: y = 1 / (1 + exp(-x)).

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Sign : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise sign: y = sign(x), returning -1 for x<0, 0 for x==0, +1 for x>0.

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Sin : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise sine: y = sin(x), defined for all real x with y in [-1, 1].

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Sinh : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise hyperbolic sine: y = sinh(x), defined for all real x.

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Softmax : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Softmax normalized exponential along a selected axis.

Public Functions

Tensor operator()(const Tensor &x, int64_t axis) const#
void operator()(const Tensor &x, int64_t axis, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Softmax needs the full input slice to compute each output value; aliasing input/output would overwrite values needed for later positions.

class SoftmaxCrossEntropyLoss : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

SoftmaxCrossEntropyLoss computes the cross-entropy loss between the (un-normalized) softmax distribution of scores and integer class indices given by labels. Optionally supports per-class weights and an ignore_index value used to mask labels that should not contribute to the loss. The kernel always returns the loss tensor and the log-probability tensor (same shape and dtype as scores); the caller is free to ignore log_prob when the node does not request it.

Public Functions

std::pair<Tensor, Tensor> operator()(const Tensor &scores, const Tensor &labels, const Tensor *weights, const std::string &reduction, bool has_ignore_index, int64_t ignore_index) const#
Parameters:
  • scores – Input scores of shape (N, C) or (N, C, D1, ..., Dk).

  • labels – Integer class indices of shape (N) or (N, D1, ..., Dk).

  • weightsOptional rank-1 tensor of length C; nullptr means unweighted.

  • reduction – One of "none", "sum", or "mean".

  • has_ignore_index – Whether ignore_index is set.

  • ignore_index – Class index to ignore (only used when has_ignore_index is true).

Returns:

Pair (loss, log_prob) with the loss tensor (shape per reduction) and the log-probability tensor (same shape and dtype as scores).

inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

The kernel allocates new outputs; it does not support input/output aliasing.

class Softplus : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise softplus activation: y = ln(1 + exp(x)).

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Softsign : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise softsign activation: y = x / (1 + |x|).

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Sqrt : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise square root: y = sqrt(x), with x >= 0 (NaN otherwise).

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class STFT : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Reference implementation of the ONNX STFT operator (opset 17).

Computes the Short-time Fourier Transform of signal by sliding a (optionally windowed) DFT of length frame_length over the signal axis with step frame_step. signal must be a floating-point tensor of shape [batch_size, signal_length, 1] (real input) or [batch_size, signal_length, 2] (interleaved real/imaginary parts). The output has shape [batch_size, n_frames, dft_unique_bins, 2] where n_frames = (signal_length - frame_length) / frame_step + 1 and dft_unique_bins is floor(frame_length / 2) + 1 when onesided is true (the default for real input) or frame_length otherwise.

window is an optional 1-D tensor with shape [frame_length]; pass nullptr to skip the windowing step. frame_length is an optional pointer to a 0-D INT32/INT64 tensor; pass nullptr to derive frame_length from the window shape. At least one of window or frame_length must be provided.

Public Functions

Tensor operator()(const Tensor &signal, const Tensor &frame_step, const Tensor *window, const Tensor *frame_length, bool onesided = true) const#
void operator()(const Tensor &signal, const Tensor &frame_step, const Tensor *window, const Tensor *frame_length, bool onesided, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

The output shape generally differs from the input, so storage cannot be shared.

class Sub : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise subtraction with NumPy-style broadcasting.

Public Functions

Tensor operator()(const Tensor &x, const Tensor &y) const#
void operator()(const Tensor &x, const Tensor &y, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise binary kernel: the output buffer may alias an input buffer when that input is not broadcast-expanded (i.e. its shape equals the output shape).

class Sum : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise sum of a list of tensors with NumPy-style (multidirectional) broadcasting. At least one input is required. All inputs must share the same float dtype (FLOAT or DOUBLE); the output has the broadcast shape of all inputs and the same dtype.

Public Functions

Tensor operator()(const std::vector<Tensor> &inputs) const#
void operator()(const std::vector<Tensor> &inputs, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Variadic element-wise kernel: the output buffer may alias an input buffer when that input is not broadcast-expanded (i.e. its shape equals the output shape).

class Swish : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise Swish activation: y = x * sigmoid(alpha * x). alpha defaults to 1.0 to match the ONNX schema (opset 24).

Public Functions

Tensor operator()(const Tensor &x, float alpha = 1.0f) const#
void operator()(const Tensor &x, float alpha, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Tan : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise tangent: y = tan(x); undefined at x = (2k+1) * pi/2.

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class Tanh : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise hyperbolic tangent: y = tanh(x), with y in (-1, 1).

Public Functions

Tensor operator()(const Tensor &x) const#
void operator()(const Tensor &x, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class ThresholdedRelu : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Element-wise thresholded rectified linear unit: y = x for x > alpha, y = 0 otherwise. alpha defaults to 1.0 to match the ONNX schema.

Public Functions

Tensor operator()(const Tensor &x, float alpha = 1.0f) const#
void operator()(const Tensor &x, float alpha, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Element-wise unary kernel: the output buffer may alias the input buffer.

class TopK : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_math_kernels.h>

Reference implementation of the TopK operator (opsets 1, 10, 11).

Selects the k largest (or smallest, when largest is false) values along axis from the input tensor x and returns them together with the corresponding indices. axis is interpreted modulo the rank of x (negative values count from the back). When sorted is true (the default) the returned values are sorted descending (or ascending when largest is false); ties along axis are broken by the lower index. When sorted is false the order of the returned values is unspecified by the ONNX schema; this reference implementation still returns them sorted to keep the output deterministic.

Returns a std::pair<Tensor, Tensor> where the first tensor (Values) has the same dtype as x and the second tensor (Indices) is an INT64 tensor. Both share the shape of x with the axis dimension replaced by k.

Public Functions

std::pair<Tensor, Tensor> operator()(const Tensor &x, int64_t k, int64_t axis = -1, bool largest = true, bool sorted = true) const#
void operator()(const Tensor &x, int64_t k, int64_t axis, bool largest, bool sorted, Tensor &values, Tensor &indices) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

TopK output shape differs from the input along axis (k vs. axis_dim) and the Indices output has a different dtype (int64), so the output buffers cannot safely alias either input buffer.