include_reduction_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 ArgMax : public onnx_light::onnx_kernels::kernel::ArgReduce#
#include <include_reduction_kernels.h>

ArgMax wrapper around :class:ArgReduce configured for the maximum.

Public Functions

inline explicit ArgMax(const KernelContext &ctx)#
class ArgMin : public onnx_light::onnx_kernels::kernel::ArgReduce#
#include <include_reduction_kernels.h>

ArgMin wrapper around :class:ArgReduce configured for the minimum.

Public Functions

inline explicit ArgMin(const KernelContext &ctx)#
class ArgReduce : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_reduction_kernels.h>

Returns the indices of the maximum (ArgMax) or minimum (ArgMin) values of a FLOAT input data along a single axis.

The output is always an INT64 tensor whose shape matches data with the reduced axis either dropped (keepdims = false) or replaced by 1 (keepdims = true, the default).

axis follows ONNX semantics and accepts values in [-rank(data), rank(data) - 1]. select_last_index (default false, ONNX opset 12+) selects the index of the last occurrence of the extremum when multiple positions are tied; otherwise the first occurrence is selected.

Subclassed by onnx_light::onnx_kernels::kernel::ArgMax, onnx_light::onnx_kernels::kernel::ArgMin

Public Types

enum class Mode#

Values:

enumerator kMax#
enumerator kMin#

Public Functions

inline ArgReduce(const KernelContext &ctx, Mode mode)#
Tensor operator()(const Tensor &data, int64_t axis = 0, bool keepdims = true, bool select_last_index = false) const#
void operator()(const Tensor &data, int64_t axis, bool keepdims, bool select_last_index, Tensor &output) const#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

The INT64 output buffer never aliases the FLOAT input buffer.

Private Members

Mode mode_#
class ReduceL1 : public onnx_light::onnx_kernels::kernel::ReduceL1L2#
#include <include_reduction_kernels.h>

ReduceL1 wrapper around :class:ReduceL1L2 configured for the L1 norm.

Public Functions

inline explicit ReduceL1(const KernelContext &ctx)#
class ReduceL1L2 : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_reduction_kernels.h>

Shared FLOAT kernel for ReduceL1, ReduceL2 and ReduceSumSquare.

ReduceL1 computes the sum of absolute values along the reduced axes: y = sum(|x|, axes). ReduceL2 computes the Euclidean (L2) norm: y = sqrt(sum(x * x, axes)). ReduceSumSquare computes the sum of squared values: y = sum(x * x, axes) — i.e. the L2 norm without the final square root. The empty-set identity for all three is 0 (so reducing over a size-0 axis yields a zero-filled output).

The interface mirrors :class:ReduceMinMax: the axes may either be omitted (reduce-all unless noop_with_empty_axes == true) or supplied as an int64 tensor (opset 18+). Negative axes follow ONNX semantics.

Subclassed by onnx_light::onnx_kernels::kernel::ReduceL1, onnx_light::onnx_kernels::kernel::ReduceL2, onnx_light::onnx_kernels::kernel::ReduceSumSquare

Public Types

enum class Mode#

Values:

enumerator kL1#
enumerator kL2#
enumerator kSumSquare#

Public Functions

inline ReduceL1L2(const KernelContext &ctx, Mode mode)#
Tensor operator()(const Tensor &data, bool keepdims = true, bool noop_with_empty_axes = false) const#
void operator()(const Tensor &data, bool keepdims, bool noop_with_empty_axes, Tensor &output) const#
Tensor operator()(const Tensor &data, const Tensor &axes, bool keepdims = true, bool noop_with_empty_axes = false) const#
void operator()(const Tensor &data, const Tensor &axes, bool keepdims, bool noop_with_empty_axes, Tensor &output) const#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Private Members

Mode mode_#
class ReduceL2 : public onnx_light::onnx_kernels::kernel::ReduceL1L2#
#include <include_reduction_kernels.h>

ReduceL2 wrapper around :class:ReduceL1L2 configured for the L2 norm.

Public Functions

inline explicit ReduceL2(const KernelContext &ctx)#
class ReduceLogSum : public onnx_light::onnx_kernels::kernel::ReduceLogSumOp#
#include <include_reduction_kernels.h>

ReduceLogSum wrapper around :class:ReduceLogSumOp configured for log(sum(x, axes)).

Public Functions

inline explicit ReduceLogSum(const KernelContext &ctx)#
class ReduceLogSumExp : public onnx_light::onnx_kernels::kernel::ReduceLogSumOp#
#include <include_reduction_kernels.h>

ReduceLogSumExp wrapper around :class:ReduceLogSumOp configured for log(sum(exp(x), axes)).

Public Functions

inline explicit ReduceLogSumExp(const KernelContext &ctx)#
class ReduceLogSumOp : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_reduction_kernels.h>

Shared FLOAT/DOUBLE kernel for ReduceLogSum and ReduceLogSumExp.

ReduceLogSum computes y = log(sum(x, axes)). ReduceLogSumExp computes y = log(sum(exp(x), axes)) using the numerically-stable max-shift trick: y = m + log(sum(exp(x - m), axes)) where m = max(x, axes). For both operators the empty-set identity is -inf (log(0)); when reducing over a size-0 axis the result is -inf.

The interface mirrors :class:ReduceL1L2: the axes may either be omitted (reduce-all unless noop_with_empty_axes == true) or supplied as an int64 tensor (opset 18+). Negative axes follow ONNX semantics.

Subclassed by onnx_light::onnx_kernels::kernel::ReduceLogSum, onnx_light::onnx_kernels::kernel::ReduceLogSumExp

Public Types

enum class Mode#

Values:

enumerator kLogSum#
enumerator kLogSumExp#

Public Functions

inline ReduceLogSumOp(const KernelContext &ctx, Mode mode)#
Tensor operator()(const Tensor &data, bool keepdims = true, bool noop_with_empty_axes = false) const#
void operator()(const Tensor &data, bool keepdims, bool noop_with_empty_axes, Tensor &output) const#
Tensor operator()(const Tensor &data, const Tensor &axes, bool keepdims = true, bool noop_with_empty_axes = false) const#
void operator()(const Tensor &data, const Tensor &axes, bool keepdims, bool noop_with_empty_axes, Tensor &output) const#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Private Members

Mode mode_#
class ReduceMax : public onnx_light::onnx_kernels::kernel::ReduceMinMax#
#include <include_reduction_kernels.h>

ReduceMax wrapper around :class:ReduceMinMax configured for maximum.

Public Functions

inline explicit ReduceMax(const KernelContext &ctx)#
class ReduceMean : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_reduction_kernels.h>

Arithmetic mean reduction of a FLOAT input data along the dimensions listed in the optional axes int64 tensor. ReduceMean computes y = sum(x, axes) / N where N is the product of the reduced dimension sizes. ONNX does not define a value for the empty-set case (division by zero); this kernel returns 0 in that case for consistency with the other reduction kernels.

The interface mirrors :class:ReduceMinMax / :class:ReduceL1L2: the axes may either be omitted (reduce-all unless noop_with_empty_axes == true) or supplied as an int64 tensor (opset 18+). Negative axes follow ONNX semantics.

Public Functions

Tensor operator()(const Tensor &data, bool keepdims = true, bool noop_with_empty_axes = false) const#
void operator()(const Tensor &data, bool keepdims, bool noop_with_empty_axes, Tensor &output) const#
Tensor operator()(const Tensor &data, const Tensor &axes, bool keepdims = true, bool noop_with_empty_axes = false) const#
void operator()(const Tensor &data, const Tensor &axes, bool keepdims, bool noop_with_empty_axes, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#
class ReduceMin : public onnx_light::onnx_kernels::kernel::ReduceMinMax#
#include <include_reduction_kernels.h>

ReduceMin wrapper around :class:ReduceMinMax configured for minimum.

Public Functions

inline explicit ReduceMin(const KernelContext &ctx)#
class ReduceMinMax : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_reduction_kernels.h>

Shared FLOAT kernel for ReduceMax and ReduceMin.

Subclassed by onnx_light::onnx_kernels::kernel::ReduceMax, onnx_light::onnx_kernels::kernel::ReduceMin

Public Types

enum class Mode#

Values:

enumerator kMax#
enumerator kMin#

Public Functions

inline ReduceMinMax(const KernelContext &ctx, Mode mode)#
Tensor operator()(const Tensor &data, bool keepdims = true, bool noop_with_empty_axes = false) const#
void operator()(const Tensor &data, bool keepdims, bool noop_with_empty_axes, Tensor &output) const#
Tensor operator()(const Tensor &data, const Tensor &axes, bool keepdims = true, bool noop_with_empty_axes = false) const#
void operator()(const Tensor &data, const Tensor &axes, bool keepdims, bool noop_with_empty_axes, Tensor &output) const#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Private Members

Mode mode_#
class ReduceProd : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_reduction_kernels.h>

Product reduction of a FLOAT input data along the dimensions listed in the optional axes int64 tensor. ReduceProd computes y = prod(x, axes); the empty-set identity is 1 (so reducing over a size-0 axis yields a one-filled output, and noop_with_empty_axes skips the reduction entirely).

The interface mirrors :class:ReduceMinMax / :class:ReduceL1L2: the axes may either be omitted (reduce-all unless noop_with_empty_axes == true) or supplied as an int64 tensor (opset 18+). Negative axes follow ONNX semantics.

Public Functions

Tensor operator()(const Tensor &data, bool keepdims = true, bool noop_with_empty_axes = false) const#
void operator()(const Tensor &data, bool keepdims, bool noop_with_empty_axes, Tensor &output) const#
Tensor operator()(const Tensor &data, const Tensor &axes, bool keepdims = true, bool noop_with_empty_axes = false) const#
void operator()(const Tensor &data, const Tensor &axes, bool keepdims, bool noop_with_empty_axes, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#
class ReduceSum : public onnx_light::onnx_kernels::kernel::KernelBase#
#include <include_reduction_kernels.h>

Sum reduction of a FLOAT or DOUBLE input data along the dimensions listed in the optional axes int64 tensor. If axes is omitted (or empty), the kernel reduces over all dimensions unless noop_with_empty_axes is true in which case it performs an identity copy.

Public Functions

Tensor operator()(const Tensor &data, bool keepdims = true, bool noop_with_empty_axes = false) const#

axes omitted: reduces over all dimensions of data (the default when noop_with_empty_axes is false) or returns a copy of data when noop_with_empty_axes is true.

void operator()(const Tensor &data, bool keepdims, bool noop_with_empty_axes, Tensor &output) const#
Tensor operator()(const Tensor &data, const Tensor &axes, bool keepdims = true, bool noop_with_empty_axes = false) const#

Explicit axes: an int64 tensor whose elements are the dimensions to reduce. Negative axis values are accepted (ONNX semantics: axis in [-rank(data), rank(data) - 1]).

void operator()(const Tensor &data, const Tensor &axes, bool keepdims, bool noop_with_empty_axes, Tensor &output) const#
inline explicit KernelBase(const KernelContext &ctx)#

Public Static Functions

static inline constexpr bool CanRunInPlace() noexcept#

Output shape generally differs from the input shape, so the output buffer cannot in general alias the input buffer.

class ReduceSumSquare : public onnx_light::onnx_kernels::kernel::ReduceL1L2#
#include <include_reduction_kernels.h>

ReduceSumSquare wrapper around :class:ReduceL1L2 configured for the sum of squared values (L2 norm without the final square root).

Public Functions

inline explicit ReduceSumSquare(const KernelContext &ctx)#