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_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 ArgMax : public onnx_light::onnx_kernels::kernel::ArgReduce#
- #include <include_reduction_kernels.h>
ArgMaxwrapper around :class:ArgReduceconfigured for the maximum.Public Functions
-
inline explicit ArgMax(const KernelContext &ctx)#
-
inline explicit ArgMax(const KernelContext &ctx)#
-
class ArgMin : public onnx_light::onnx_kernels::kernel::ArgReduce#
- #include <include_reduction_kernels.h>
ArgMinwrapper around :class:ArgReduceconfigured for the minimum.Public Functions
-
inline explicit ArgMin(const KernelContext &ctx)#
-
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 inputdataalong a singleaxis.The output is always an INT64 tensor whose shape matches
datawith the reducedaxiseither dropped (keepdims = false) or replaced by1(keepdims = true, the default).axisfollows ONNX semantics and accepts values in[-rank(data), rank(data) - 1].select_last_index(defaultfalse, 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 Functions
-
inline ArgReduce(const KernelContext &ctx, Mode mode)#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
The INT64 output buffer never aliases the FLOAT input buffer.
-
inline ArgReduce(const KernelContext &ctx, Mode mode)#
-
class ReduceL1 : public onnx_light::onnx_kernels::kernel::ReduceL1L2#
- #include <include_reduction_kernels.h>
ReduceL1wrapper around :class:ReduceL1L2configured for the L1 norm.Public Functions
-
inline explicit ReduceL1(const KernelContext &ctx)#
-
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,ReduceL2andReduceSumSquare.ReduceL1computes the sum of absolute values along the reduced axes:y = sum(|x|, axes).ReduceL2computes the Euclidean (L2) norm:y = sqrt(sum(x * x, axes)).ReduceSumSquarecomputes 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 is0(so reducing over a size-0 axis yields a zero-filled output).The interface mirrors :class:
ReduceMinMax: theaxesmay either be omitted (reduce-all unlessnoop_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 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#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
-
inline ReduceL1L2(const KernelContext &ctx, Mode mode)#
-
class ReduceL2 : public onnx_light::onnx_kernels::kernel::ReduceL1L2#
- #include <include_reduction_kernels.h>
ReduceL2wrapper around :class:ReduceL1L2configured for the L2 norm.Public Functions
-
inline explicit ReduceL2(const KernelContext &ctx)#
-
inline explicit ReduceL2(const KernelContext &ctx)#
-
class ReduceLogSum : public onnx_light::onnx_kernels::kernel::ReduceLogSumOp#
- #include <include_reduction_kernels.h>
ReduceLogSumwrapper around :class:ReduceLogSumOpconfigured forlog(sum(x, axes)).Public Functions
-
inline explicit ReduceLogSum(const KernelContext &ctx)#
-
inline explicit ReduceLogSum(const KernelContext &ctx)#
-
class ReduceLogSumExp : public onnx_light::onnx_kernels::kernel::ReduceLogSumOp#
- #include <include_reduction_kernels.h>
ReduceLogSumExpwrapper around :class:ReduceLogSumOpconfigured forlog(sum(exp(x), axes)).Public Functions
-
inline explicit ReduceLogSumExp(const KernelContext &ctx)#
-
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
ReduceLogSumandReduceLogSumExp.ReduceLogSumcomputesy = log(sum(x, axes)).ReduceLogSumExpcomputesy = log(sum(exp(x), axes))using the numerically-stablemax-shifttrick:y = m + log(sum(exp(x - m), axes))wherem = 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: theaxesmay either be omitted (reduce-all unlessnoop_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 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#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
-
inline ReduceLogSumOp(const KernelContext &ctx, Mode mode)#
-
class ReduceMax : public onnx_light::onnx_kernels::kernel::ReduceMinMax#
- #include <include_reduction_kernels.h>
ReduceMaxwrapper around :class:ReduceMinMaxconfigured for maximum.Public Functions
-
inline explicit ReduceMax(const KernelContext &ctx)#
-
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
dataalong the dimensions listed in the optionalaxesint64 tensor.ReduceMeancomputesy = sum(x, axes) / NwhereNis the product of the reduced dimension sizes. ONNX does not define a value for the empty-set case (division by zero); this kernel returns0in that case for consistency with the other reduction kernels.The interface mirrors :class:
ReduceMinMax/ :class:ReduceL1L2: theaxesmay either be omitted (reduce-all unlessnoop_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#
-
Tensor operator()(const Tensor &data, bool keepdims = true, bool noop_with_empty_axes = false) const#
-
class ReduceMin : public onnx_light::onnx_kernels::kernel::ReduceMinMax#
- #include <include_reduction_kernels.h>
ReduceMinwrapper around :class:ReduceMinMaxconfigured for minimum.Public Functions
-
inline explicit ReduceMin(const KernelContext &ctx)#
-
inline explicit ReduceMin(const KernelContext &ctx)#
-
class ReduceMinMax : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_reduction_kernels.h>
Shared FLOAT kernel for
ReduceMaxandReduceMin.Subclassed by onnx_light::onnx_kernels::kernel::ReduceMax, onnx_light::onnx_kernels::kernel::ReduceMin
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#
Public Static Functions
-
static inline constexpr bool CanRunInPlace() noexcept#
-
inline ReduceMinMax(const KernelContext &ctx, Mode mode)#
-
class ReduceProd : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_reduction_kernels.h>
Product reduction of a FLOAT input
dataalong the dimensions listed in the optionalaxesint64 tensor.ReduceProdcomputesy = prod(x, axes); the empty-set identity is1(so reducing over a size-0 axis yields a one-filled output, andnoop_with_empty_axesskips the reduction entirely).The interface mirrors :class:
ReduceMinMax/ :class:ReduceL1L2: theaxesmay either be omitted (reduce-all unlessnoop_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#
-
Tensor operator()(const Tensor &data, bool keepdims = true, bool noop_with_empty_axes = false) const#
-
class ReduceSum : public onnx_light::onnx_kernels::kernel::KernelBase#
- #include <include_reduction_kernels.h>
Sum reduction of a FLOAT or DOUBLE input
dataalong the dimensions listed in the optionalaxesint64 tensor. Ifaxesis omitted (or empty), the kernel reduces over all dimensions unlessnoop_with_empty_axesis 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#
axesomitted: reduces over all dimensions ofdata(the default whennoop_with_empty_axesis false) or returns a copy ofdatawhennoop_with_empty_axesis 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:axisin[-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.
-
Tensor operator()(const Tensor &data, bool keepdims = true, bool noop_with_empty_axes = false) const#
-
class ReduceSumSquare : public onnx_light::onnx_kernels::kernel::ReduceL1L2#
- #include <include_reduction_kernels.h>
ReduceSumSquarewrapper around :class:ReduceL1L2configured for the sum of squared values (L2 norm without the final square root).Public Functions
-
inline explicit ReduceSumSquare(const KernelContext &ctx)#
-
inline explicit ReduceSumSquare(const KernelContext &ctx)#
-
class ArgMax : public onnx_light::onnx_kernels::kernel::ArgReduce#
-
namespace kernel
-
namespace onnx_kernels