fn
logsumexp_op
→TensorImplPtrint logsumexp_op(const int & a, const int & axes, bool keepdims)Python wrappers
Public Python APIs implemented by this engine symbol.Numerically-stable via the max-shift trick.
Composite over max_op + sub_op + exp_op +
sum_op + log_op + add_op (+ squeeze_op).
Subtracting the per-reduction-group max keeps the largest exponent
argument at so the rest underflow rather than overflow; the offset
is added back outside the log. Gradient flows through MaxBackward,
SubBackward, ExpBackward, SumBackward, LogBackward, and
AddBackward automatically — no dedicated backward node is registered.
Math
See Also
logaddexp_op — two-operand elementwise variant.
Parameters
aTensorImplPtrInput tensor.
axesvector<int>Axes to reduce. Negative values wrap modulo
a.ndim. An empty list reduces over all axes per the primitive's convention.keepdimsboolIf
true, retain size-1 placeholders at the reduced positions. Otherwise, the reduced axes are squeezed off (in descending order so each remaining index stays valid through the sequential squeeze loop).Returns
TensorImplPtrReduced tensor. Dtype matches a.
Notes
The intermediate max_op is computed with keepdims=true so
the broadcast subtract is well defined; the optional axis collapse is
done at the end on the keep-dim result.