---
title: "ClikaRT::ops::logsumexp"
sidebar_label: "logsumexp"
description: "Numerically stable log(sum(exp(x))) over dims. \\[ \\mathrm{out} = \\log \\sum_{i \\in \\text{dims}} e^{x_i} \\] Computed with the max-shift trick, so large magnitudes do not overflow."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## logsumexp() {#logsumexp}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`logsumexp`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `dims`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `keepdim` `=` `false`<br />
)

</div>

Numerically stable [`log`](./log.md#log)`(sum(exp(x)))` over `dims`.

$$
\mathrm{out} = \log \sum_{i \in \text{dims}} e^{x_i}
$$

Computed with the max-shift trick, so large magnitudes do not overflow. `dims` is required here (no reduce-all default).

**Parameters**

- `input`: the input tensor; float dtype.
- `dims`: axes to reduce.
- `keepdim`: keep reduced axes as size-1 dims; default false.

**Returns:** the reduced tensor; shape = `input` minus `dims`.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) on an out-of-range `dims` entry or a non-float input.

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 4388

</div>
