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_NAMESPACEso 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 withONNX_APIcompile without modification.Namespace alias so that ONNX C++ code (and consumers such as onnxruntime) that refers to the literal
onnxnamespace — rather than theONNX_NAMESPACEmacro — resolves to the onnx-light namespace. The standard onnx package lives innamespace onnx; onnx-light usesonnx_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 fromonnx.-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class Add : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Element-wise addition with NumPy-style broadcasting.
Public Functions
-
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).
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class BlackmanWindow : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
BlackmanWindow function evaluated at
sizeinteger samples. Whenperiodicis true the window is computed as if of lengthsize+1and the last sample is discarded (matches NumPy/ONNX conventions).Public Functions
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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)).alphadefaults to 1.0 to match the ONNX schema. OnlyFLOATinputs are accepted (matching the v12 schema).Public Functions
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
minandmaxare optional scalar tensors (since opset 11); when omitted, the corresponding bound defaults tostd::numeric_limits<T>::lowest()andstd::numeric_limits<T>::max(). Whenmin > maxthe operator returnsmaxfor 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/maxmay benullptrto use the dtype-specific default bound. When provided, each must be a 0-D (scalar) tensor whose dtype matchesx.
-
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.
-
Tensor operator()(const Tensor &x, const Tensor *min = nullptr, const Tensor *max = nullptr) const#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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:CumSumwith addition replaced by multiplication; inexclusivemode the starting value is 1 (multiplicative identity).
-
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
exclusiveflag, 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). Thereverseflag, when true, performs the summation in the opposite direction alongaxis.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. Theexclusivemode reads the previous position’s input before writing, which is also safe in row-major order when iterating outward from the starting end.
-
Tensor operator()(const Tensor &x, const Tensor &axis, bool exclusive = false, bool reverse = false) const#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class DFT : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Reference implementation of the ONNX
DFToperator (since opset 17; in opset 20 theaxisattribute moved to an optional third input).Computes the (one-dimensional) discrete Fourier Transform of
inputalongaxis.inputmust be a floating-point tensor of rank >= 2, where the trailing dimension is1(real-valued samples) or2(interleaved real/imaginary parts). The returned tensor has the same rank asinput; its last dimension is2(complex output) except for IRFFT (onesided=1andinverse=1), in which case it is1.When
dft_lengthis specified the signal is zero-padded or truncated alongaxis; otherwise the axis dimension is used (or2 * (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#
axisis the signal axis (must satisfy-rank <= axis,axis != -1andaxis < rank - 1).dft_lengthis a pointer to a 0-D INT32/INT64 tensor; passnullptrto 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.
-
Tensor operator()(const Tensor &input, const Tensor *dft_length, int64_t axis, bool onesided = false, bool inverse = false) const#
-
class Div : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Element-wise division with NumPy-style broadcasting.
Public Functions
-
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).
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class Einsum : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Reference implementation of the
Einsumoperator (opset 12).Evaluates the Einstein summation expressed by
equationover 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.
-
class Elu : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Element-wise exponential linear unit:
y = xforx >= 0andy = alpha * (exp(x) - 1)otherwise.alphadefaults to 1.0 to match the ONNX schema.Public Functions
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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 formulationy = 0.5 * x * (1 + erf(x / sqrt(2)))is used; whenapproximate == "tanh"the tanh-based approximationy = 0.5 * x * (1 + tanh(sqrt(2/pi) * (x + 0.044715 * x^3)))is used.Public Functions
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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/transBcontrol whether A and B are transposed (0 = no, non-zero = yes);alphaandbetaare scalar multipliers. Whencisnullptrthe 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)#
-
Tensor operator()(const Tensor &a, const Tensor &b, const Tensor *c, float alpha, float beta, int64_t transA, int64_t transB) const#
-
class HammingWindow : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
HammingWindow function evaluated at
sizeinteger samples. Whenperiodicis true the window is computed as if of lengthsize+1and the last sample is discarded (matches NumPy/ONNX conventions).Public Functions
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class HannWindow : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
HannWindow function evaluated at
sizeinteger samples. Whenperiodicis true the window is computed as if of lengthsize+1and the last sample is discarded (matches NumPy/ONNX conventions).Public Functions
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
inline explicit KernelBase(const KernelContext &ctx)#
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class LeakyRelu : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Element-wise leaky rectified linear unit:
y = xforx >= 0andy = alpha * xotherwise.alphadefaults to 0.01 to match the ONNX schema.Public Functions
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class MatMulInteger : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Reference
MatMulIntegerkernel (opset 10). ComputesY = matmul(A - a_zero_point, B - b_zero_point)with INT8/UINT8 inputs and an INT32 output.a_zero_pointandb_zero_pointare 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_pointmay 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.
-
Tensor operator()(const Tensor &a, const Tensor &b, const Tensor &a_zero_point, const Tensor &b_zero_point) const#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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 typeoutput_dtype(defaultFLOAT).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.
-
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#
-
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
-
inline explicit KernelBase(const KernelContext &ctx)#
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class Mod : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Element-wise modulo with NumPy-style broadcasting. The
fmodflag controls the semantics:fmod == 0(default): integer modulo whose sign follows the divisor (Python%/numpy.mod). Only valid for integer dtypes.fmod == 1: Cfmodsemantics 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
-
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
-
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).
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class Neg : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Element-wise negation: y = -x. Mirrors the upstream ONNX
Negreference implementation (np.negative). Only the FLOAT dtype is supported.Public Functions
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
inputtensor of log-probabilities of shape(N, C)or(N, C, D1, ..., Dk)and integer class indicestargetof shape(N)or(N, D1, ..., Dk). UnlikeSoftmaxCrossEntropyLoss, 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).weight – Optional rank-1 tensor of length
C;nullptrmeans unweighted.reduction – One of
"none","sum", or"mean".has_ignore_index – Whether
ignore_indexis set.ignore_index – Class index to ignore (only used when
has_ignore_indexis true).
- Returns:
Loss tensor whose shape depends on
reduction: matches the shape oftargetfor"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.
-
Tensor operator()(const Tensor &input, const Tensor &target, const Tensor *weight, const std::string &reduction, bool has_ignore_index, int64_t ignore_index) const#
-
class Pow : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Element-wise exponentiation
z = x ^ ywith NumPy-style multidirectional broadcasting (since opset 7). Unlike most binary element-wise kernels,Powallowsxandyto have different dtypes: the output dtype always matches the dtype of the basex(per the ONNX schema,Zis constrained toTwhileYis constrained to the broaderT1).Supported base dtypes (
T): FLOAT, INT32, INT64. Supported exponent dtypes (T1): FLOAT, INT32, INT64, UINT32, UINT64. Integer base / integer exponent pairs evaluate the power indoubleprecision and cast the result back to the base dtype, matching the reference behaviour of NumPy’snumpy.powerand the upstream ONNX backend test cases.Public Functions
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class PRelu : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Element-wise parametric ReLU:
y = xwhenx >= 0andy = slope * xotherwise. Theslopetensor is unidirectionally broadcastable tox(the standard NumPy-style multidirectional broadcasting rules apply here as well — the unidirectional case is a strict subset). Float-input semantics preserve+inf/-infbecause the kernel branches on the sign ofxrather than evaluatingmax(0, x) + slope * min(0, x)(which would yieldNaNfor infinite inputs; see microsoft/onnxruntime#28732).Public Functions
-
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).
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class Selu : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Element-wise scaled exponential linear unit:
y = gamma * xforx > 0andy = gamma * (alpha * exp(x) - alpha)forx <= 0.alphaandgammadefault 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#
-
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.
-
Tensor operator()(const Tensor &x, float alpha = 1.67326319217681884765625f, float gamma = 1.05070102214813232421875f) const#
-
class Shrink : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Element-wise Shrink activation:
y = x + biasifx < -lambd,y = x - biasifx > lambd,y = 0otherwise.lambddefaults to 0.5 andbiasdefaults to 0.Public Functions
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class Softmax : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Softmax normalized exponential along a selected axis.
Public Functions
-
inline explicit KernelBase(const KernelContext &ctx)#
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
scoresand integer class indices given bylabels. Optionally supports per-class weights and anignore_indexvalue 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 asscores); the caller is free to ignorelog_probwhen 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).weights – Optional rank-1 tensor of length
C;nullptrmeans unweighted.reduction – One of
"none","sum", or"mean".has_ignore_index – Whether
ignore_indexis set.ignore_index – Class index to ignore (only used when
has_ignore_indexis true).
- Returns:
Pair
(loss, log_prob)with the loss tensor (shape perreduction) and the log-probability tensor (same shape and dtype asscores).
-
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.
-
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#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class Softsign : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Element-wise softsign activation: y = x / (1 + |x|).
Public Functions
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class STFT : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Reference implementation of the ONNX
STFToperator (opset 17).Computes the Short-time Fourier Transform of
signalby sliding a (optionally windowed) DFT of lengthframe_lengthover the signal axis with stepframe_step.signalmust 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]wheren_frames = (signal_length - frame_length) / frame_step + 1anddft_unique_binsisfloor(frame_length / 2) + 1whenonesidedis true (the default for real input) orframe_lengthotherwise.windowis an optional 1-D tensor with shape[frame_length]; passnullptrto skip the windowing step.frame_lengthis an optional pointer to a 0-D INT32/INT64 tensor; passnullptrto deriveframe_lengthfrom thewindowshape. At least one ofwindoworframe_lengthmust 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.
-
Tensor operator()(const Tensor &signal, const Tensor &frame_step, const Tensor *window, const Tensor *frame_length, bool onesided = true) const#
-
class Sub : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Element-wise subtraction with NumPy-style broadcasting.
Public Functions
-
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).
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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).
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class Swish : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Element-wise Swish activation: y = x * sigmoid(alpha * x).
alphadefaults to 1.0 to match the ONNX schema (opset 24).Public Functions
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
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.
alphadefaults to 1.0 to match the ONNX schema.Public Functions
-
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.
-
inline explicit KernelBase(const KernelContext &ctx)#
-
class TopK : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_math_kernels.h>
Reference implementation of the
TopKoperator (opsets 1, 10, 11).Selects the
klargest (or smallest, whenlargestis false) values alongaxisfrom the input tensorxand returns them together with the corresponding indices.axisis interpreted modulo the rank ofx(negative values count from the back). Whensortedis true (the default) the returned values are sorted descending (or ascending whenlargestis false); ties alongaxisare broken by the lower index. Whensortedis 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 asxand the second tensor (Indices) is anINT64tensor. Both share the shape ofxwith theaxisdimension replaced byk.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)#
-
std::pair<Tensor, Tensor> operator()(const Tensor &x, int64_t k, int64_t axis = -1, bool largest = true, bool sorted = true) const#
-
class Abs : public onnx_light::onnx_kernels::kernel::KernelBase#
-
namespace kernel
-
namespace onnx_kernels